visual-studio - 在 TFS 上安装 Visual Studio npm 获取最新
问题描述
当 TFS“获取最新”引入添加开发依赖项的 package.json 更改时,Visual Studio 2017 不会自动运行“npm install”。这会破坏依赖于新包的“监视”模式下的所有 gulp 任务。
我能看到导致 npm install 的唯一方法是手动触摸 package.json 或重新启动 VS。
有没有办法在“获取最新”时触发“npm install”?
解决方案
这是我确定的解决方案的线框图。tl;dr - 在 Gulp 中实现我自己的 package.json 观察器来停止 Webpack、运行npm install
和重新启动 Webpack。
const gulp = require('gulp');
const install = require('gulp-install');
const watch = require('glob-watcher');
const webpack = require('webpack');
gulp.task('default', ['webpack']);
gulp.task('webpack', function () {
// Start the initial Webpack build.
let webpackCompiler = webpack({
// ...
watch: true
// ...
});
// Set up a watcher to kill Webpack, run 'npm install', and restart Webpack when package.json changes.
let packageWatcher = watch('./package.json', { events: ['change'] }, () => {
packageWatcher.close();
console.log('Stopped package.json watcher.');
webpackWatcher.close(() => {
console.log('Stopped Webpack watcher.');
gulp.start('npm-install-then-webpack');
});
});
console.log('Started package.json watcher.');
});
gulp.task('npm-install', function (callback) {
gulp.src('./package.json')
.pipe(install(callback));
});
gulp.task('npm-install-then-webpack', ['npm-install'], function () {
gulp.start('webpack');
});
推荐阅读
- python - 给定 2 个数据帧在第二个数据帧中搜索匹配值并返回值
- python - 如何在 python foluim 中更改颜色图标题的文本颜色?
- ios - 如何在 xcframwork ios 中访问公共 swift 文件?
- flutter - Flutter:预定的通知日期时间
- cheerio - Cheerio 奇怪的解析
- javascript - 减少方法 os 具有条件的对象数组:是数字吗?
- ios - Json 请求检索结果但只显示第一个结果
- python - 无法使用简单循环操作 Dataframe 来计算 zscore
- php - PHP Preg_match 字符串中的每个单词以查找与包含禁用单词的数组中的所有项目的匹配项
- javascript - 如何使用javascript调整多个图像大小并使用ajax保存在mysql中