Files
test-repo/scripts/test-dist.js
T
Lucas Duailibe 889b7dab79 Run tests using the standalone build in an empty context (#4668)
Validate that our build is stripping all the "native" dependencies (native modules and env vars).
2018-06-12 15:05:40 -03:00

38 lines
900 B
JavaScript

#!/usr/bin/env node
"use strict";
const path = require("path");
const shell = require("shelljs");
const tempy = require("tempy");
shell.config.fatal = true;
const rootDir = path.join(__dirname, "..");
const distDir = path.join(rootDir, "dist");
const file = shell.exec("npm pack", { cwd: distDir }).stdout.trim();
const tarPath = path.join(distDir, file);
const tmpDir = tempy.directory();
shell.config.silent = true;
shell.exec("npm init -y", { cwd: tmpDir });
shell.exec(`npm install "${tarPath}"`, { cwd: tmpDir });
shell.config.silent = false;
const cmd = `yarn test --color --runInBand ${
process.env.TEST_STANDALONE ? "tests/" : ""
}`;
const code = shell.exec(cmd, {
cwd: rootDir,
env: Object.assign({}, process.env, {
NODE_ENV: "production",
AST_COMPARE: "1",
PRETTIER_DIR: path.join(tmpDir, "node_modules/prettier")
}),
shell: true
}).code;
process.exit(code);