-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixing tests by increasing timeouts and formatting code with prettier.
- Loading branch information
Showing
11 changed files
with
483 additions
and
468 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
'use strict'; | ||
"use strict"; | ||
|
||
module.exports = { | ||
pack: require('./lib/pack'), | ||
push: require('./lib/push'), | ||
restore: require('./lib/restore') | ||
pack: require("./lib/pack"), | ||
push: require("./lib/push"), | ||
restore: require("./lib/restore"), | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,108 +1,102 @@ | ||
'use strict'; | ||
|
||
exports.pack = function(nuspecFile, options) { | ||
var args = ['pack', nuspecFile]; | ||
|
||
var withoutValues = [ | ||
'build', | ||
'symbols', | ||
'excludeEmptyDirectories', | ||
'includeReferencedProjects', | ||
'noDefaultExcludes', | ||
'tool' | ||
]; | ||
|
||
var withValues = [ | ||
'version', | ||
'outputDirectory', | ||
'basePath', | ||
'exclude', | ||
'properties', | ||
'minClientVersion', | ||
'msBuildVersion', | ||
'verbosity', | ||
'suffix', | ||
]; | ||
|
||
withValues.forEach(function(prop) { | ||
var value = options[prop]; | ||
if(value) { | ||
args.push('-' + prop); | ||
args.push(value); | ||
} | ||
}); | ||
|
||
withoutValues.forEach(function(prop) { | ||
var value = options[prop]; | ||
if(value) { | ||
args.push('-' + prop); | ||
} | ||
}); | ||
|
||
args.push('-nopackageanalysis'); | ||
args.push('-noninteractive'); | ||
|
||
return args; | ||
"use strict"; | ||
|
||
exports.pack = function (nuspecFile, options) { | ||
var args = ["pack", nuspecFile]; | ||
|
||
var withoutValues = [ | ||
"build", | ||
"symbols", | ||
"excludeEmptyDirectories", | ||
"includeReferencedProjects", | ||
"noDefaultExcludes", | ||
"tool", | ||
]; | ||
|
||
var withValues = [ | ||
"version", | ||
"outputDirectory", | ||
"basePath", | ||
"exclude", | ||
"properties", | ||
"minClientVersion", | ||
"msBuildVersion", | ||
"verbosity", | ||
"suffix", | ||
]; | ||
|
||
withValues.forEach(function (prop) { | ||
var value = options[prop]; | ||
if (value) { | ||
args.push("-" + prop); | ||
args.push(value); | ||
} | ||
}); | ||
|
||
withoutValues.forEach(function (prop) { | ||
var value = options[prop]; | ||
if (value) { | ||
args.push("-" + prop); | ||
} | ||
}); | ||
|
||
args.push("-nopackageanalysis"); | ||
args.push("-noninteractive"); | ||
|
||
return args; | ||
}; | ||
|
||
exports.push = function(nupkg, options) { | ||
var args = ['push', nupkg]; | ||
exports.push = function (nupkg, options) { | ||
var args = ["push", nupkg]; | ||
|
||
var withValues = [ | ||
'source', | ||
'apiKey', | ||
'timeout', | ||
'configFile', | ||
'verbosity' | ||
]; | ||
var withValues = ["source", "apiKey", "timeout", "configFile", "verbosity"]; | ||
|
||
withValues.forEach(function(prop) { | ||
var value = options[prop]; | ||
if(value) { | ||
args.push('-' + prop); | ||
args.push(value); | ||
} | ||
}); | ||
withValues.forEach(function (prop) { | ||
var value = options[prop]; | ||
if (value) { | ||
args.push("-" + prop); | ||
args.push(value); | ||
} | ||
}); | ||
|
||
args.push('-noninteractive'); | ||
args.push("-noninteractive"); | ||
|
||
return args; | ||
return args; | ||
}; | ||
|
||
exports.restore = function(nupkg, options) { | ||
var args = ['restore', nupkg]; | ||
|
||
var withValues = [ | ||
'source', | ||
'configFile', | ||
'packagesDirectory', | ||
'solutionDirectory', | ||
'msBuildVersion', | ||
'verbosity' | ||
]; | ||
|
||
var withoutValues = [ | ||
'noCache', | ||
'requireConsent', | ||
'disableParallelProcessing' | ||
]; | ||
|
||
withValues.forEach(function(prop) { | ||
var value = options[prop]; | ||
if(value) { | ||
args.push('-' + prop); | ||
args.push(value); | ||
} | ||
}); | ||
|
||
withoutValues.forEach(function(prop) { | ||
var value = options[prop]; | ||
if(value) { | ||
args.push('-' + prop); | ||
} | ||
}); | ||
|
||
args.push('-noninteractive'); | ||
|
||
return args; | ||
exports.restore = function (nupkg, options) { | ||
var args = ["restore", nupkg]; | ||
|
||
var withValues = [ | ||
"source", | ||
"configFile", | ||
"packagesDirectory", | ||
"solutionDirectory", | ||
"msBuildVersion", | ||
"verbosity", | ||
]; | ||
|
||
var withoutValues = [ | ||
"noCache", | ||
"requireConsent", | ||
"disableParallelProcessing", | ||
]; | ||
|
||
withValues.forEach(function (prop) { | ||
var value = options[prop]; | ||
if (value) { | ||
args.push("-" + prop); | ||
args.push(value); | ||
} | ||
}); | ||
|
||
withoutValues.forEach(function (prop) { | ||
var value = options[prop]; | ||
if (value) { | ||
args.push("-" + prop); | ||
} | ||
}); | ||
|
||
args.push("-noninteractive"); | ||
|
||
return args; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,80 +1,84 @@ | ||
'use strict'; | ||
|
||
var cproc = require('child_process'); | ||
var through = require('through2'); | ||
var fs = require('fs-extra'); | ||
var log = require('fancy-log'); | ||
var PluginError = require('plugin-error'); | ||
var argsFor = require('./argsFor'); | ||
var validFor = require('./validFor'); | ||
var path = require('path'); | ||
var File = require('vinyl'); | ||
|
||
module.exports = function(options) { | ||
options = options || {}; | ||
options.nuget = options.nuget || './nuget.exe'; | ||
options.outputDirectory = options.outputDirectory || './.gulp-nuget'; | ||
options.maxBuffer = options.maxBuffer || 200*1024; | ||
|
||
return through.obj(function(file, encoding, done) { | ||
if(!validFor.pack(file)) { | ||
return done(null, file); | ||
} | ||
|
||
var self = this; | ||
var args = argsFor.pack(file.path, options); | ||
var opts = { maxBuffer: options.maxBuffer }; | ||
|
||
fs.mkdirs(options.outputDirectory, function(err) { | ||
if(err) throw new PluginError('gulp-nuget', err); | ||
|
||
cproc.execFile(options.nuget, args, opts, function(err, stdout) { | ||
if(err) throw new PluginError('gulp-nuget', err); | ||
|
||
log(stdout.trim()); | ||
|
||
var files = findNupkgs(stdout); | ||
pushFiles.call(self, files, done); | ||
}); | ||
|
||
}); | ||
}); | ||
"use strict"; | ||
|
||
var cproc = require("child_process"); | ||
var through = require("through2"); | ||
var fs = require("fs-extra"); | ||
var log = require("fancy-log"); | ||
var PluginError = require("plugin-error"); | ||
var argsFor = require("./argsFor"); | ||
var validFor = require("./validFor"); | ||
var path = require("path"); | ||
var File = require("vinyl"); | ||
|
||
module.exports = function (options) { | ||
options = options || {}; | ||
options.nuget = options.nuget || "./nuget.exe"; | ||
options.outputDirectory = options.outputDirectory || "./.gulp-nuget"; | ||
options.maxBuffer = options.maxBuffer || 200 * 1024; | ||
|
||
return through.obj(function (file, encoding, done) { | ||
if (!validFor.pack(file)) { | ||
return done(null, file); | ||
} | ||
|
||
var self = this; | ||
var args = argsFor.pack(file.path, options); | ||
var opts = { maxBuffer: options.maxBuffer }; | ||
|
||
fs.mkdirs(options.outputDirectory, function (err) { | ||
if (err) throw new PluginError("gulp-nuget", err); | ||
|
||
cproc.execFile(options.nuget, args, opts, function (err, stdout) { | ||
if (err) throw new PluginError("gulp-nuget", err); | ||
|
||
log(stdout.trim()); | ||
|
||
var files = findNupkgs(stdout); | ||
pushFiles.call(self, files, done); | ||
}); | ||
}); | ||
}); | ||
}; | ||
|
||
function pushFiles(files, done) { | ||
var self = this; | ||
|
||
files.forEach(function(file, index) { | ||
fs.readFile(file, function(err, data) { | ||
if(err) throw new PluginError('gulp-nuget', err); | ||
|
||
self.push(new File({ | ||
base: path.dirname(file), | ||
path: file, | ||
contents: data | ||
})); | ||
|
||
if((index + 1) === files.length) { | ||
fs.remove('./.gulp-nuget', done); | ||
} | ||
}); | ||
}); | ||
var self = this; | ||
|
||
files.forEach(function (file, index) { | ||
fs.readFile(file, function (err, data) { | ||
if (err) throw new PluginError("gulp-nuget", err); | ||
|
||
self.push( | ||
new File({ | ||
base: path.dirname(file), | ||
path: file, | ||
contents: data, | ||
}) | ||
); | ||
|
||
if (index + 1 === files.length) { | ||
fs.remove("./.gulp-nuget", done); | ||
} | ||
}); | ||
}); | ||
} | ||
|
||
function findNupkgs(stdout) { | ||
var matches = []; | ||
var nupkg = new RegExp('[\'"„“](.+\.nupkg)[\'"”]', 'ig'); | ||
var nupkg = new RegExp("['\"„“](.+.nupkg)['\"”]", "ig"); | ||
|
||
var match = nupkg.exec(stdout); | ||
|
||
while(match != null) { | ||
while (match != null) { | ||
matches.push(match[1]); | ||
match = nupkg.exec(stdout); | ||
} | ||
|
||
if(!matches || !matches.length) { | ||
throw new PluginError('gulp-nuget', 'Could not detect any output .nupkg files from nuget.'); | ||
if (!matches || !matches.length) { | ||
throw new PluginError( | ||
"gulp-nuget", | ||
"Could not detect any output .nupkg files from nuget." | ||
); | ||
} | ||
|
||
return matches; | ||
}; | ||
} |
Oops, something went wrong.