Skip to content

Commit

Permalink
Fix: Properly utilize env.cwd with --verify flag
Browse files Browse the repository at this point in the history
  • Loading branch information
Romanx authored and phated committed Dec 21, 2017
1 parent d8b14e8 commit 7523f64
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ function handleArguments(env) {
if (opts.verify) {
var pkgPath = opts.verify !== true ? opts.verify : 'package.json';
if (path.resolve(pkgPath) !== path.normalize(pkgPath)) {
pkgPath = path.join(env.configBase, pkgPath);
pkgPath = path.join(env.cwd, pkgPath);
}
log.info('Verifying plugins in ' + pkgPath);
return getBlacklist(function(err, blacklist) {
Expand Down
7 changes: 3 additions & 4 deletions test/flags-verify.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ var child = require('child_process');
lab.experiment('flag: --verify', function() {

lab.test('dependencies with invalid dependency', function(done) {
child.exec('node ' + __dirname + '/../bin/gulp.js --verify "packages/invalid-package.json" --cwd "./test/fixtures/packages/"', function(err, stdout) {
child.exec('node ' + __dirname + '/../bin/gulp.js --verify "invalid-package.json" --cwd "./test/fixtures/packages/"', function(err, stdout) {
// Ignore err as the verify failure is considered a error state.
stdout = stdout.replace(/\\/g, '/').split('\n');
code.expect(stdout[1]).to.contain('Blacklisted plugins found in this project:');
Expand All @@ -17,16 +17,15 @@ lab.experiment('flag: --verify', function() {
});

lab.test('dependencies with valid dependency', function(done) {
child.exec('node ' + __dirname + '/../bin/gulp.js --verify "packages/valid-package.json" --cwd "./test/fixtures/packages/"', function(err, stdout) {
child.exec('node ' + __dirname + '/../bin/gulp.js --verify "valid-package.json" --cwd "./test/fixtures/packages/"', function(err, stdout) {
stdout = stdout.replace(/\\/g, '/').split('\n');
code.expect(stdout[1]).to.contain(' There are no blacklisted plugins in this project');
done(err);
});
});

lab.test('default args with invalid dependency', function(done) {
child.exec('node ' + __dirname + '/../bin/gulp.js --verify "packages/package.json" --cwd ./test/fixtures/packages/', function(err, stdout) {
console.log(stdout);
child.exec('node ' + __dirname + '/../bin/gulp.js --verify "package.json" --cwd ./test/fixtures/packages/', function(err, stdout) {
// Ignore err as the verify failure is considered a error state.
stdout = stdout.replace(/\\/g, '/').split('\n');
code.expect(stdout[1]).to.contain('Blacklisted plugins found in this project:');
Expand Down

0 comments on commit 7523f64

Please sign in to comment.