Skip to content

Commit

Permalink
build: spellcheck-commit and .changelogrc no longer use shelljs
Browse files Browse the repository at this point in the history
  • Loading branch information
Xunnamius committed Feb 22, 2021
1 parent e77df0b commit b3633c3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
12 changes: 6 additions & 6 deletions .changelogrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const debug = require('debug')(

const escapeRegExpStr = require('escape-string-regexp');
const semver = require('semver');
const sjx = require('shelljs');
const execa = require('execa');

// ? Commit types that trigger releases by default (using angular configuration)
// ? See https://github.com/semantic-release/commit-analyzer/blob/master/lib/default-release-rules.js
Expand All @@ -31,12 +31,12 @@ const SKIP_COMMANDS = '[skip ci], [ci skip], [skip cd], [cd skip]'.split(', ');

debug('SKIP_COMMANDS:', SKIP_COMMANDS);

sjx.config.silent = !process.env.DEBUG;

// ! XXX: dark magic to synchronously deal with this async package
const wait = sjx.exec(
`node -e 'require("conventional-changelog-angular").then(o => console.log(o.writerOpts.transform.toString()));'`
);
// TODO: fork this package and offer a sync export instead of this dark magic
const wait = execa.sync('node', [
'-e',
'require("conventional-changelog-angular").then(o => console.log(o.writerOpts.transform.toString()));'
]).stdout;

if (wait.code != 0) throw new Error('failed to acquire angular transformation');

Expand Down
8 changes: 4 additions & 4 deletions spellcheck-commit.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@
const spellcheck = require('spellchecker');
const pkg = require('./package.json');
const read = require('fs').promises.readFile;
const sjx = require('shelljs');
const execa = require('execa');

const debug = require('debug')(`${require('./package.json').name}:spellcheck-commit`);

sjx.config.silent = !process.env.DEBUG;

const tryToRead = async (path) => {
try {
debug(`attempting to read ${path}`);
Expand Down Expand Up @@ -67,7 +65,9 @@ const keys = (obj) => Object.keys(obj).map(splitOutWords);
...keys(pkg.dependencies),
...keys(pkg.devDependencies),
...keys(pkg.scripts),
...splitOutWords(sjx.exec('git log --format="%B" HEAD~1').stdout).slice(0, -1)
...splitOutWords(
(await execa('git', ['log', '--format="%B"', 'HEAD~1'])).stdout
).slice(0, -1)
]
.flat()
.filter(Boolean)
Expand Down

0 comments on commit b3633c3

Please sign in to comment.