diff --git a/README.md b/README.md index 4983033..5d66306 100644 --- a/README.md +++ b/README.md @@ -44,6 +44,7 @@ GH_TOKEN=ghtoken GH_USER=username NPM_TOKEN=npmtoken npx zx-bulk-release [opts] | `--include-private` | Include `private` packages | `false` | | `--concurrency` | `build/publish` threads limit | `os.cpus.length` | | `--no-build` | Skip `buildCmd` invoke | | +| `--no-test` | Disable `testCmd` run | | | `--no-npm-fetch` | Disable npm artifacts fetching | | | `--only-workspace-deps` | Recognize only `workspace:` deps as graph edges | | | `--dry-run` / `--no-publish` | Disable any publish logic | | diff --git a/src/main/js/processor/exec.js b/src/main/js/processor/exec.js index 3604b1f..fc9512e 100644 --- a/src/main/js/processor/exec.js +++ b/src/main/js/processor/exec.js @@ -3,7 +3,7 @@ import {log} from '../log.js' import {$} from 'zx-extra' export const exec = async (pkg, name) => { - const cmd = tpl(pkg.config[name], {...pkg, ...pkg.context}) + const cmd = tpl(pkg.context.flags[name] ?? pkg.config[name], {...pkg, ...pkg.context}) const now = Date.now() if (cmd) { diff --git a/src/main/js/processor/release.js b/src/main/js/processor/release.js index 69e5e27..cf45efa 100644 --- a/src/main/js/processor/release.js +++ b/src/main/js/processor/release.js @@ -10,6 +10,7 @@ import {analyze} from '../steps/analyze.js' import {build} from '../steps/build.js' import {publish} from '../steps/publish.js' import {clean} from '../steps/clean.js' +import {test} from '../steps/test.js' export const run = async ({cwd = process.cwd(), env, flags = {}} = {}) => within(async () => { const {version: zbrVersion} = createRequire(import.meta.url)('../../../../package.json') @@ -54,6 +55,10 @@ export const run = async ({cwd = process.cwd(), env, flags = {}} = {}) => within report.setStatus('building', name) await build(pkg, _exec) } + if (flags.test !== false) { + report.setStatus('testing', name) + await test(pkg, _exec) + } if (!flags.dryRun && flags.publish !== false) { report.setStatus('publishing', name) await publish(pkg, _exec) diff --git a/src/main/js/steps/build.js b/src/main/js/steps/build.js index 01340f6..9727233 100644 --- a/src/main/js/steps/build.js +++ b/src/main/js/steps/build.js @@ -16,7 +16,7 @@ export const build = memoizeBy(async (pkg, run = exec, flags = {}, self = build) if (!pkg.fetched) { await run(pkg, 'buildCmd') - await run(pkg, 'testCmd') + // await run(pkg, 'testCmd') } pkg.built = true diff --git a/src/main/js/steps/test.js b/src/main/js/steps/test.js new file mode 100644 index 0000000..72eefed --- /dev/null +++ b/src/main/js/steps/test.js @@ -0,0 +1,16 @@ +import {$, within} from 'zx-extra' +import {memoizeBy} from '../util.js' +import {exec} from '../processor/exec.js' +// import {traverseDeps} from "../processor/deps.js"; + +export const test = memoizeBy(async (pkg, run = exec, flags = {}, self = test) => within(async () => { + $.scope = pkg.name + + // await traverseDeps({pkg, packages: pkg.context.packages, cb: async({pkg}) => self(pkg, run, flags, self)}) + + if (!pkg.fetched) { + await run(pkg, 'testCmd') + } + + pkg.tested = true +}))