chmontgomery / gulp-shrinkwrap Goto Github PK
View Code? Open in Web Editor NEWRun npm shrinkwrap from a gulp task
Run npm shrinkwrap from a gulp task
As a developer, I want control over where the package.json
and npm-shrinkwrap.json
files are generated to. I also want control over whether or not I'm modifying the package.json
file and whether or not I'm running npm shrinkwrap
.
The way this plugin is used is unintuitive. It would be nice if it was refactored so that the two different features are two different steps and each allows you to pipe the result to an arbitrary location.
//cc @chovy
I have a very simple gulp task setup to run like so:
gulp.task('shrinkwrap', function() {
return gulp.src('package.json')
.pipe(shrinkwrap())
.pipe(gulp.dest('./'))
.pipe(gutil.log(gutil.colors.green('Build Successful!')));
});
But when I run it, it keeps running into the same error. I'm assuming it's a bug, because I searched the internet for solutions, none found. Since this is the only plugin affected, I figured it's most likely a bug. However, it does write the actual npm-shrinkwrap.json
file.
You can ignore the 'Connected to MEAN Developer Database' in between.
Dependency resolution fails for [email protected]
, which is a dependency of [email protected]
.
Here is the error:
module.js:474
throw err;
^
Error: Cannot find module 'internal/fs'
at Function.Module._resolveFilename (module.js:472:15)
at Function.Module._load (module.js:420:25)
at Module.require (module.js:500:17)
at require (internal/module.js:20:19)
at evalmachine.<anonymous>:17:20
at Object.<anonymous> (/Users/ethertyper/WebstormProjects/WestlakeAPC.github.io/node_modules/gulp-shrinkwrap/node_modules/npm/node_modules/graceful-fs/fs.js:11:1)
at Module._compile (module.js:573:32)
at Object.Module._extensions..js (module.js:582:10)
at Module.load (module.js:490:32)
at tryModuleLoad (module.js:449:12)
And here is the dependency tree:
├─┬ [email protected]
│ ├── [email protected]
│ └─┬ [email protected]
│ └── [email protected]
Using verison 2.4.0
I created a task
gulp.task('shrinkwrap', () => {
return gulp.src('package.json')
.pipe(shrinkwrap())
.pipe(gulp.dest('./'));
});
But, when the npm-shrinkwrap.json
file is created, it is including all of my dev dependencies.
I was able to work around this by changing the above task to:
gulp.task('shrinkwrap', () => {
return gulp.src('package.json')
.pipe(shrinkwrap({production: true}))
.pipe(gulp.dest('./'));
});
I think this is due to the upgrade from [email protected]
to [email protected]
Directory contents:
- gulpfile.js
+ /dist
- package.json
- package-lock.json
gulpfile.js
const gulp = require('gulp');
const shrinkwrap = require('gulp-shrinkwrap');
gulp.task('npm-shrinkwrap', () => {
return gulp.src('dist/package.json')
.pipe(shrinkwrap())
.pipe('dist/');
});
gulp.task('default', [ 'npm-shrinkwrap' ]);
Running gulp from the top level directory produces the following output:
Starting 'npm-shrinkwrap'...
npm WARN invalid config loglevel="notice"
wrote npm-shrinkwrap.json
And the contents of dist/ are:
+ /dist
- package.json
- package-lock.json
- npm-shrinkwrap.json
However, if I cd into dist/ and run npm shrinkwrap
this is the output and directory listing:
npm notice package-lock.json has been renamed to npm-shrinkwrap.json. npm-shrinkwrap.json will be used for future installations.
+ /dist
- package.json
- npm-shrinkwrap.json
Steps to reproduce:
Expected results: package-lock.json is renamed to npm-shrinkwrap.json
Actual results: a new npm-shrinkwrap.json file is generated and the existing package-lock.json file is left intact.
It would be great to see shrinkwrap({dev:true})
in the documentation to know it supports shrinkwrap options.
gulp.src("package.json")
.pipe(shrinkwrap({dev:true}))
It would be great if gulp-shrinkwrap supported passing options (like --dev
) to shrinkwrap.
gulp.task('shrinkwrap', function () {
return gulp.src('package.json')
.pipe(shrinkwrap())
.pipe(gulp.dest('./dist'));
});
I expect to see ./dist/npm-shrinkgwrap.json
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.