Skip to content

Instantly share code, notes, and snippets.

@pxwise
Last active January 30, 2019 08:11
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pxwise/c4833557930a5141c4e3c752347e2f2e to your computer and use it in GitHub Desktop.
Save pxwise/c4833557930a5141c4e3c752347e2f2e to your computer and use it in GitHub Desktop.
Approximate `npm prune --production` using `yarn remove`
/**
* Approximate `npm prune --production` using `yarn remove`.
* @see https://github.com/yarnpkg/yarn/issues/696
*/
const exec = require('child_process').exec;
const devDependencies = Object.keys(require('./package.json').devDependencies).join(' ');
const command = 'yarn remove ' + devDependencies;
const child = exec(command, (err, stdout, stderr) => {
if (err) throw err;
console.log(`stdout: \n${stdout}`);
console.log(`stderr: \n${stderr}`);
});
@lifeiscontent
Copy link

@pxwise how is this called? node ./yarn-prune.js?

@crazyyi
Copy link

crazyyi commented Mar 28, 2018

How to use this?

@loopmode
Copy link

Here's a version that supports workspaces: https://gist.github.com/loopmode/318e881454dc0498874a4e764d3dce55

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment