Skip to content

Commit

Permalink
feat: pass --check to pkgfiles (#48)
Browse files Browse the repository at this point in the history
  • Loading branch information
popomore authored and atian25 committed Apr 17, 2017
1 parent 115e532 commit 7b0c995
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/cmd/pkgfiles.js
Expand Up @@ -6,18 +6,24 @@ class PkgfilesCommand extends Command {
constructor(rawArgv) {
super(rawArgv);
this.usage = 'Usage: egg-bin pkgfiles';
this.options = {
check: {
description: 'assert whether it\'s same',
},
};
}

get description() {
return 'Generate pkg.files automatically';
}

* run({ cwd }) {
* run({ cwd, argv }) {
const args = [
'--entry', 'app',
'--entry', 'config',
'--entry', '*.js',
];
if (argv.check) args.push('--check');
const pkgfiles = require.resolve('ypkgfiles/bin/ypkgfiles.js');
yield this.helper.forkNode(pkgfiles, args, { cwd });
}
Expand Down
11 changes: 11 additions & 0 deletions test/lib/cmd/pkgfiles.test.js
Expand Up @@ -27,4 +27,15 @@ describe('test/lib/cmd/pkgfiles.test.js', () => {
'app.js',
]);
});

it('should check pkg.files', function* () {
cwd = path.join(__dirname, '../../fixtures/pkgfiles');
yield fs.writeFile(path.join(cwd, 'package.json'), '{}');

yield coffee.fork(eggBin, [ 'pkgfiles', '--check' ], { cwd })
.debug()
.expect('stderr', /pkg.files should equal to \[ app, config, app.js ], but got \[ {2}]/)
.expect('code', 1)
.end();
});
});

0 comments on commit 7b0c995

Please sign in to comment.