Skip to content

Commit

Permalink
tests/refactor ~ move version consistency checks from package lint to…
Browse files Browse the repository at this point in the history
… distribution test
  • Loading branch information
rivy committed Aug 13, 2022
1 parent 3abd0d9 commit 6db56d6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
"# lint # check for package code 'lint'": "",
"lint": "run-s --silent +:max-node-8 && shx echo \"[lint] WARN Lint checks skipped [for NodeJS < v10]\" 1>&2 || run-p --print-name \"lint:*\"",
"# lint:commits # check for commit flaws (using `commitlint` and `cspell`)": "",
"lint:commits": "run-s --silent _:v_tag:missing || run-p --silent \"_:lint:commits.new:*\"",
"lint:commits": "run-p --silent \"_:lint:commits:new:*\"",
"# lint:editorconfig # check for EditorConfig format flaws (using `editorconfig-checker`)": "",
"lint:editorconfig": "editorconfig-checker -config .ecrc.JS.json",
"# lint:lint # check for code 'lint' (using `eslint`)": "",
Expand Down Expand Up @@ -149,8 +149,6 @@
"_:vcs-clean-err": "run-s --silent _:vcs-clean || ( shx echo \"[vcs] ERR! Uncommitted changes\" 1>&2 & exit 1 )",
"_:vcs-strictly-clean": "git status --porcelain | node -e \"process.stdin.on('data',function(_){process.exit(1);});\"",
"_:vcs-strictly-clean-err": "run-s --silent _:vcs-strictly-clean || ( shx echo \"[vcs] ERR! Uncommitted changes and/or untracked files\" 1>&2 & exit 1 )",
"_:v_tag:exists": "node -e \"v=require('./package.json').version; result=require('child_process').spawnSync('git rev-list refs/tags/v'+v,{shell:true,encoding:'utf-8'}); if (result.status != 0) {console.error('[lint] WARN Missing commit tag v'+v); process.exit(1);}\"",
"_:v_tag:missing": "run-s --silent _:v_tag:exists && exit 1 || exit 0",
"_:update:changelog": "run-s --silent _:exists:git-changelog && git changelog > CHANGELOG.mkd || shx echo \"[update] WARN CHANGELOG not updated\" 1>&2",
"_:update:dist.build": "shx rm -fr dist/cjs dist/esm && shx mkdir -p dist/cjs dist/esm && shx cp -r build/cjs/src/* dist/cjs && shx cp -r build/esm/src/* dist/esm",
"_:update:dist.normalizeEOL": "eolConverter lf dist/**/*.{cjs,js,mjs,ts,json}",
Expand Down
11 changes: 11 additions & 0 deletions test/dist.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,4 +139,15 @@ if (!process.env.npm_config_test_dist) {
t.true(included);
});
});

test('package version has matching Git/VCS version tag', (t) => {
t.log({ version: pkg.version });

// eslint-disable-next-line security/detect-child-process
const result = require('child_process').spawnSync('git rev-list refs/tags/v' + pkg.version, {
shell: true,
encoding: 'utf-8',
});
t.is(result.status, 0);
});
}

0 comments on commit 6db56d6

Please sign in to comment.