Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: pass --check to pkgfiles #48

Merged
merged 1 commit into from
Apr 17, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion lib/cmd/pkgfiles.js
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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();
});
});