代码之家  ›  专栏  ›  技术社区  ›  crenshaw-dev

在tfs上安装Visual Studio NPM获取最新版本

  •  1
  • crenshaw-dev  · 技术社区  · 7 年前

    当tfs“get latest”引入一个package.json更改,添加了dev依赖项时,Visual Studio 2017不会自动运行“npm install”。这将中断依赖于新包的“监视”模式下的任何吞咽任务。

    我能看到导致NPM安装的唯一方法是手动触摸package.json或重启vs.

    1 回复  |  直到 7 年前
        1
  •  0
  •   crenshaw-dev    7 年前

    npm install

    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');
    });