Skip to content

Commit

Permalink
Merge pull request #784 from electron-userland/yarn-prune-no-lockfile
Browse files Browse the repository at this point in the history
Don't create yarn.lock when pruning with Yarn
  • Loading branch information
malept committed Jan 2, 2018
2 parents bc2080c + dabdfac commit 969a2b4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
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

0 comments on commit 969a2b4

Please sign in to comment.