Files
gulp-nuget-restore/index.js
binarytox1n c126124dba Enabled support for multiple sln files
Fixed bug where each additional piped file would add to the list of parameters for the nuget restore call. Each file is now added to a local array instead of pushing to a global array.
2018-07-27 11:26:26 -05:00

45 lines
1.2 KiB
JavaScript

'use strict';
var gutil = require('gulp-util');
var through = require('through2');
var execFile = require('child_process').execFile;
module.exports = function (options) {
var nugetPath = __dirname + "./nuget.exe";
var monoPath = null;
var targetFile = nugetPath;
var cmdArgs = ["restore"];
if (options) {
nugetPath = options.nugetPath || nugetPath;
monoPath = options.monoPath || monoPath;
if (options.additionalArgs && options.additionalArgs.length > 0) {
cmdArgs = cmdArgs.concat(options.additionalArgs);
}
}
if (monoPath && monoPath.length > 0) {
targetFile = monoPath;
cmdArgs.unshift(nugetPath);
}
return through.obj(function (file, enc, cb) {
if (!file || !file.path) {
cb(null, file);
return;
}
var localArgs = cmdArgs.concat(file.path);
return execFile(targetFile, localArgs, function (error, stdout, stderror) {
if (stdout.trim()) {
gutil.log(stdout);
}
if (stderror.trim()){
gutil.log(stderror);
}
if (error) {
throw error;
}
cb(null, file);
});
});
};