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

Don't create yarn.lock when pruning with Yarn #784

Merged
merged 1 commit into from Jan 2, 2018
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion prune.js
Expand Up @@ -12,7 +12,7 @@ function pruneCommand (packageManager) {
case 'cnpm':
return `${packageManager} prune --production`
case 'yarn':
return `${packageManager} install --production --no-bin-links`
return `${packageManager} install --production --no-bin-links --no-lockfile`
}
}

Expand Down
15 changes: 13 additions & 2 deletions test/prune.js
Expand Up @@ -7,6 +7,11 @@ const test = require('ava')
const util = require('./_util')
const which = require('which')

function assertYarnLockDoesntExist (t, resourcesPath) {
return fs.pathExists(path.join(resourcesPath, 'app', 'yarn.lock'))
.then(exists => t.false(exists, 'yarn.lock should NOT exist in packaged app'))
}

function createPruneOptionTest (t, baseOpts, prune, testMessage) {
const opts = Object.assign({}, baseOpts, {
name: 'pruneTest',
Expand All @@ -23,13 +28,19 @@ function createPruneOptionTest (t, baseOpts, prune, testMessage) {
}).then(stats => {
t.true(stats.isDirectory(), 'npm dependency should exist under app/node_modules')
return fs.pathExists(path.join(resourcesPath, 'app', 'node_modules', 'run-waterfall'))
}).then(exists => t.is(!prune, exists, testMessage))
}).then(exists => {
t.is(!prune, exists, testMessage)
if (opts.packageManager === 'yarn') {
return assertYarnLockDoesntExist(t, resourcesPath)
}
return Promise.resolve()
})
}

test('pruneCommand returns the correct command when passing a known package manager', t => {
t.is(prune.pruneCommand('npm'), 'npm prune --production', 'passing npm gives the npm prune command')
t.is(prune.pruneCommand('cnpm'), 'cnpm prune --production', 'passing cnpm gives the cnpm prune command')
t.is(prune.pruneCommand('yarn'), 'yarn install --production --no-bin-links', 'passing yarn gives the yarn "prune command"')
t.is(prune.pruneCommand('yarn'), 'yarn install --production --no-bin-links --no-lockfile', 'passing yarn gives the yarn "prune command"')
})

test('pruneCommand returns undefined when the package manager is unknown', t => {
Expand Down