Skip to content

Commit

Permalink
Use run() from cli-argv-util to test cli
Browse files Browse the repository at this point in the history
  • Loading branch information
dpilafian committed Jul 11, 2023
1 parent 76b44bb commit 531c797
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
6 changes: 3 additions & 3 deletions package.json
Expand Up @@ -82,15 +82,15 @@
},
"dependencies": {
"chalk": "~5.3",
"cli-argv-util": "~1.1",
"cli-argv-util": "~1.2",
"fancy-log": "~2.0",
"slash": "~5.1"
},
"devDependencies": {
"@types/fancy-log": "~2.0",
"@types/node": "~20.4",
"@typescript-eslint/eslint-plugin": "~5.61",
"@typescript-eslint/parser": "~5.61",
"@typescript-eslint/eslint-plugin": "~6.0",
"@typescript-eslint/parser": "~6.0",
"add-dist-header": "~1.1",
"assert-deep-strict-equal": "~1.1",
"copy-file-util": "~1.1",
Expand Down
8 changes: 2 additions & 6 deletions spec/mocha.spec.js
Expand Up @@ -3,7 +3,7 @@

// Imports
import { assertDeepStrictEqual } from 'assert-deep-strict-equal';
import { execSync } from 'node:child_process';
import { cliArgvUtil } from 'cli-argv-util';
import { revWebAssets } from 'rev-web-assets';
import assert from 'assert';
import fs from 'fs';
Expand Down Expand Up @@ -150,11 +150,7 @@ describe('Correct error is thrown', () => {

////////////////////////////////////////////////////////////////////////////////
describe('Executing the CLI', () => {
const run = (posix) => {
const name = Object.keys(pkg.bin).sort()[0];
const command = process.platform === 'win32' ? posix.replaceAll('\\ ', '" "') : posix;
return execSync(command.replace(name, 'node bin/cli.js'), { stdio: 'inherit' });
};
const run = (posix) => cliArgvUtil.run(pkg, posix);

it('with basic parameters creates the expected new menu file', () => {
run('copy-folder --cd=spec/fixtures/source subfolder --ext=.css ../target/cli');
Expand Down

0 comments on commit 531c797

Please sign in to comment.