1 parent
58905cdf57
commit
71fbd6149a
5 files changed
+45
-46
No files matched your search
@@ -99,8 +99,13 @@ jobs:
|
||||
name: dist
|
||||
path: dist
|
||||
|
||||
- name: Run Tests
|
||||
run: yarn test:dist
|
||||
- name: Run Tests (macOS)
|
||||
if: matrix.os == 'macos-latest'
|
||||
run: yarn test:dist --maxWorkers=4
|
||||
|
||||
- name: Run Tests (Linux and Windows)
|
||||
if: matrix.os != 'macos-latest'
|
||||
run: yarn test:dist --maxWorkers=2
|
||||
|
||||
standalone:
|
||||
strategy:
|
||||
@@ -117,8 +122,6 @@ jobs:
|
||||
exclude:
|
||||
- os: "macos-latest"
|
||||
node: "13"
|
||||
env:
|
||||
STANDALONE: true
|
||||
name: Node.js ${{ matrix.node }} on ${{ matrix.os }} (standalone)
|
||||
runs-on: ${{ matrix.os }}
|
||||
needs: [build]
|
||||
@@ -142,5 +145,10 @@ jobs:
|
||||
name: dist
|
||||
path: dist
|
||||
|
||||
- name: Run Tests
|
||||
run: yarn test:dist
|
||||
- name: Run Tests (macOS)
|
||||
if: matrix.os == 'macos-latest'
|
||||
run: yarn test:dist-standalone --maxWorkers=4
|
||||
|
||||
- name: Run Tests (Linux and Windows)
|
||||
if: matrix.os != 'macos-latest'
|
||||
run: yarn test:dist-standalone --maxWorkers=2
|
||||
@@ -1,5 +1,11 @@
|
||||
"use strict";
|
||||
|
||||
const installPrettier = require("./scripts/install-prettier");
|
||||
|
||||
const ENABLE_CODE_COVERAGE = !!process.env.ENABLE_CODE_COVERAGE;
|
||||
if (process.env.NODE_ENV === "production") {
|
||||
process.env.PRETTIER_DIR = installPrettier();
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
setupFiles: ["<rootDir>/tests_config/run_spec.js"],
|
||||
|
||||
+2
-1
@@ -115,7 +115,8 @@
|
||||
"prepublishOnly": "echo \"Error: must publish from dist/\" && exit 1",
|
||||
"prepare-release": "yarn && yarn build && yarn test:dist",
|
||||
"test": "jest",
|
||||
"test:dist": "node ./scripts/test-dist.js",
|
||||
"test:dist": "cross-env NODE_ENV=production jest",
|
||||
"test:dist-standalone": "cross-env NODE_ENV=production STANDALONE=1 jest tests/",
|
||||
"test:integration": "jest tests_integration",
|
||||
"perf:repeat": "yarn && yarn build && cross-env NODE_ENV=production node ./dist/bin-prettier.js --debug-repeat ${PERF_REPEAT:-1000} --loglevel debug ${PERF_FILE:-./index.js} > /dev/null",
|
||||
"perf:repeat-inspect": "yarn && yarn build && cross-env NODE_ENV=production node --inspect-brk ./dist/bin-prettier.js --debug-repeat ${PERF_REPEAT:-1000} --loglevel debug ${PERF_FILE:-./index.js} > /dev/null",
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
"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");
|
||||
|
||||
module.exports = () => {
|
||||
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;
|
||||
|
||||
return path.join(tmpDir, "node_modules/prettier");
|
||||
};
|
||||
@@ -1,39 +0,0 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
"use strict";
|
||||
|
||||
const path = require("path");
|
||||
const shell = require("shelljs");
|
||||
const tempy = require("tempy");
|
||||
const { isCI } = require("ci-info");
|
||||
|
||||
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 runInBand = isCI ? "--runInBand" : "";
|
||||
const testPath = process.env.TEST_STANDALONE ? "tests/" : "";
|
||||
const cmd = `yarn test --color ${runInBand} ${testPath}`;
|
||||
|
||||
const { code } = shell.exec(cmd, {
|
||||
cwd: rootDir,
|
||||
env: {
|
||||
...process.env,
|
||||
NODE_ENV: "production",
|
||||
AST_COMPARE: "1",
|
||||
PRETTIER_DIR: path.join(tmpDir, "node_modules/prettier"),
|
||||
},
|
||||
shell: true,
|
||||
});
|
||||
|
||||
process.exit(code);
|
||||
Reference in new issue
Block a user