项目作者: richtea

项目描述 :
A Gulp plugin that runs install commands such as npm install, bower install
高级语言: JavaScript
项目地址: git://github.com/richtea/gulp-reinstall.git
创建时间: 2020-02-07T08:17:34Z
项目社区:https://github.com/richtea/gulp-reinstall

开源协议:MIT License

下载


gulp-reinstall

gulp-reinstall is a gulp plugin to automatically install npm, bower, tsd, typings,
composer and pip packages/dependencies.

NPM

CI build
devDependency Status
License: MIT

Overview

gulp-reinstall runs package install commands based on the files found in a vinyl stream. The filename determines
the command that is run.

The default settings are:

File Found Command run
package.json npm install
bower.json bower install
tsd.json tsd reinstall --save
typings.json typings install
composer.json composer install
requirements.txt pip install -r requirements.txt

It will run the command in the directory it finds the file, so if you have configs nested in a lower
directory than your gulpfile.js, this will still work.

NOTE gulp-reinstall requires at least NodeJS 8.3.

Usage

  1. var reinstall = require('gulp-reinstall');
  2. gulp.src(['./bower.json', './package.json']).pipe(reinstall());

Options

options.commands

Type: Object

Default: null

Use this option to add or override the command to be run for a particular filename.

  1. var reinstall = require('gulp-reinstall');
  2. gulp
  3. .src(__dirname + '/templates/**')
  4. .pipe(gulp.dest('./'))
  5. .pipe(
  6. reinstall({
  7. commands: {
  8. 'package.json': 'yarn',
  9. },
  10. yarn: ['install', '--ignore-scripts', '--force'],
  11. })
  12. ); // yarn install --ignore-scripts --force

options.production

Type: Boolean

Default: false

Set to true if invocations of npm install and bower install should be appended with the --production parameter.

Example:

  1. var reinstall = require('gulp-reinstall');
  2. gulp
  3. .src(__dirname + '/templates/**')
  4. .pipe(gulp.dest('./'))
  5. // npm install --production
  6. .pipe(reinstall({ production: true }));

options.ignoreScripts

Type: Boolean

Default: false

Set to true if invocations of npm install should be appended with the --ignore-scripts parameter. Useful
for skipping postinstall scripts with npm.

Example:

  1. var reinstall = require('gulp-reinstall');
  2. gulp
  3. .src(__dirname + '/templates/**')
  4. .pipe(gulp.dest('./'))
  5. // npm install --ignore-scripts
  6. .pipe(reinstall({ ignoreScripts: true }));

options.noOptional

Type: Boolean

Default: false

Set to true if invocations of npm install should be appended with the --no-optional parameter, which will
prevent optional dependencies from being installed.

Example:

  1. var reinstall = require('gulp-reinstall');
  2. gulp
  3. .src(__dirname + '/templates/**')
  4. .pipe(gulp.dest('./'))
  5. // npm install --no-optional
  6. .pipe(reinstall({ noOptional: true }));

options.allowRoot

Type: Boolean

Default: false

Set to true if invocations of bower install should be appended with the --allow-root parameter.

Example:

  1. var reinstall = require('gulp-reinstall');
  2. gulp
  3. .src(__dirname + '/templates/**')
  4. .pipe(gulp.dest('./'))
  5. // bower install --allow-root
  6. .pipe(reinstall({ allowRoot: true }));

options.args

Type: Array | String

Default: undefined

Specify additional arguments that will be passed to all install command(s).

Example:

  1. var reinstall = require('gulp-reinstall');
  2. gulp
  3. .src(__dirname + '/templates/**')
  4. .pipe(gulp.dest('./'))
  5. .pipe(
  6. reinstall(
  7. {
  8. args: ['dev', '--no-shrinkwrap'],
  9. } // npm install --dev --no-shrinkwrap
  10. )
  11. );

options.\

Type: Array | String | Object

Default: null

Use this to specify additional arguments for a particular command.

Example:

  1. var reinstall = require('gulp-reinstall');
  2. gulp
  3. .src(__dirname + '/templates/**')
  4. .pipe(gulp.dest('./'))
  5. .pipe(
  6. reinstall({
  7. // Either a single argument as a string
  8. npm: '--production',
  9. // Or arguments as an object (transformed using Dargs: https://www.npmjs.com/package/dargs)
  10. bower: { allowRoot: true },
  11. // Or arguments as an array
  12. pip: ['--target', '.'],
  13. })
  14. );

Credits

This plugin is inspired by gulp-install, and significant parts
of the source code owe a debt to that plugin, although the main plugin logic is largely rewritten.

The gulp-install plugin appears to be no longer maintained, and is dependent on the now-deprecated
gulp-util package. gulp-reinstall removes that dependency, and also reduces the number of package
dependencies to avoid npm audit problems in future.

Contributing

Contributions are very welcome! The rest of this section describes how to set yourself up for developing gulp-reinstall.

Getting started

Just clone the repo locally and start hacking. Run npm test to see if stuff broke.

Changelog

This project follows the Keep a Changelog conventions.

Commit mesages

Please use the Angular commit guidelines when
writing commit messages.

Release process

(These are mainly notes for the maintainer, if you are contributing you won’t need to worry about this)

The release process is driven by release-it. First you create a draft
GitHub release locally by using release-it, then you publish the release through the GitHub web UI.

To create a draft release:

  1. On your local computer, checkout the main branch.
  2. Update the changelog.
  3. Run npm run release with the options you want, then follow the prompts. The two most useful options are --dry-run
    and --preRelease=alpha (or whatever the pre-release version is). Note that you need to add -- before any release-it
    arguments.

Example:

  1. npm run release -- --dry-run --preRelease=alpha

The release-it settings are configured to create a draft release on GitHub. Once the release is published within GitHub,
an automated workflow publishes the package to the npm repository.

Note: in order to run the release process, you need to set up the RELEASEMGMT_GITHUB_API_TOKEN environment variable
on your local computer. This should contain a GitHub PAT with the appropriate permissions - see the
release-it documentation for more details.

License

Licensed under the MIT License.