Files
test-repo/scripts/test-dist.js
T

38 lines
966 B
JavaScript
Raw Normal View History

2018-01-13 03:19:20 +11:00
#!/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;
2018-08-08 23:49:22 +08:00
const runInBand = process.env.CI ? "--runInBand" : "";
const testPath = process.env.TEST_STANDALONE ? "tests/" : "";
const cmd = `yarn test --color ${runInBand} ${testPath}`;
2020-01-14 23:30:18 +08:00
const { code } = shell.exec(cmd, {
2018-01-13 03:19:20 +11:00
cwd: rootDir,
env: {
...process.env,
2018-01-13 03:19:20 +11:00
NODE_ENV: "production",
AST_COMPARE: "1",
PRETTIER_DIR: path.join(tmpDir, "node_modules/prettier")
},
2018-01-13 03:19:20 +11:00
shell: true
2020-01-14 23:30:18 +08:00
});
2018-01-13 03:19:20 +11:00
process.exit(code);