Skip to content

Commit

Permalink
fix: pass if yarn remove called with no packages
Browse files Browse the repository at this point in the history
  • Loading branch information
lili2311 committed Oct 8, 2018
1 parent 68d5c6d commit 8ad52a1
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/cli/commands/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -455,8 +455,8 @@ function metaForDisplay(res, options) {
chalk.bold(rightPadWithSpaces('Organisation: ', padToLength)) + res.org,
chalk.bold(rightPadWithSpaces('Package manager: ', padToLength)) + packageManager,
];
if (options.file) {
meta.push(chalk.bold(rightPadWithSpaces('Target file: ', padToLength)) + options.file);
if (options.file || options.testedFile) {
meta.push(chalk.bold(rightPadWithSpaces('Target file: ', padToLength)) + options.file || options.testedFile);
}
if (options.docker) {
meta.push(chalk.bold(rightPadWithSpaces('Docker image: ', padToLength)) + options.path);
Expand Down
6 changes: 4 additions & 2 deletions src/lib/protect/update.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,11 @@ function update(packages, live, pkgManager) {
var devToUninstall = (upgrade.dev && upgrade.dev.map(stripVersion)) ||
[];
var toUninstall = _.uniq(prodToUninstall.concat(devToUninstall));

debug('to uninstall', toUninstall);
return uninstall(pkgManager, toUninstall, live);

if (!_.isEmpty(toUninstall)) {
return uninstall(pkgManager, toUninstall, live);
}
})
.then(function () {
var prodUpdate = (upgrade.prod ?
Expand Down
2 changes: 1 addition & 1 deletion src/lib/snyk-test/npm/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ function test(root, options) {
let policyLocations = [options['policy-path'] || root];
const targetFile = options.file || detect.detectPackageFile(root);
// this is used for Meta
options.file = targetFile;
options.testedFile = targetFile;

return Promise.resolve()
.then(() => {
Expand Down
4 changes: 4 additions & 0 deletions test/wizard-prepare.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ var proxyquire = require('proxyquire');
var sinon = require('sinon');
var spy = sinon.spy();
var _ = require('lodash');
var dir = __dirname + '/fixtures/protect-via-snyk/';
var fixture = require('./fixtures/protect-via-snyk/package.json');

var wizard = proxyquire('../src/cli/commands/protect/wizard', {
Expand Down Expand Up @@ -31,6 +32,8 @@ var wizard = proxyquire('../src/cli/commands/protect/wizard', {

test('npm - prepare is added and postinstall is removed', function (t) {
var expectedResults = _.cloneDeep(fixture);
process.chdir(dir);

return wizard.processAnswers({
// answers
'misc-test-no-monitor': true,
Expand All @@ -51,6 +54,7 @@ test('npm - prepare is added and postinstall is removed', function (t) {

test('yarn - prepare is added and postinstall is removed', function (t) {
var expectedResults = _.cloneDeep(fixture);
process.chdir(dir);
spy.reset();
return wizard.processAnswers({
// answers
Expand Down

0 comments on commit 8ad52a1

Please sign in to comment.