Skip to content

Commit 80b6115

Browse files
committed
fixing tests by increasing timeouts and formatting code with prettier.
1 parent 7bef5e0 commit 80b6115

File tree

11 files changed

+483
-468
lines changed

11 files changed

+483
-468
lines changed

index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
'use strict';
1+
"use strict";
22

33
module.exports = {
4-
pack: require('./lib/pack'),
5-
push: require('./lib/push'),
6-
restore: require('./lib/restore')
4+
pack: require("./lib/pack"),
5+
push: require("./lib/push"),
6+
restore: require("./lib/restore"),
77
};

lib/argsFor.js

Lines changed: 93 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -1,108 +1,102 @@
1-
'use strict';
2-
3-
exports.pack = function(nuspecFile, options) {
4-
var args = ['pack', nuspecFile];
5-
6-
var withoutValues = [
7-
'build',
8-
'symbols',
9-
'excludeEmptyDirectories',
10-
'includeReferencedProjects',
11-
'noDefaultExcludes',
12-
'tool'
13-
];
14-
15-
var withValues = [
16-
'version',
17-
'outputDirectory',
18-
'basePath',
19-
'exclude',
20-
'properties',
21-
'minClientVersion',
22-
'msBuildVersion',
23-
'verbosity',
24-
'suffix',
25-
];
26-
27-
withValues.forEach(function(prop) {
28-
var value = options[prop];
29-
if(value) {
30-
args.push('-' + prop);
31-
args.push(value);
32-
}
33-
});
34-
35-
withoutValues.forEach(function(prop) {
36-
var value = options[prop];
37-
if(value) {
38-
args.push('-' + prop);
39-
}
40-
});
41-
42-
args.push('-nopackageanalysis');
43-
args.push('-noninteractive');
44-
45-
return args;
1+
"use strict";
2+
3+
exports.pack = function (nuspecFile, options) {
4+
var args = ["pack", nuspecFile];
5+
6+
var withoutValues = [
7+
"build",
8+
"symbols",
9+
"excludeEmptyDirectories",
10+
"includeReferencedProjects",
11+
"noDefaultExcludes",
12+
"tool",
13+
];
14+
15+
var withValues = [
16+
"version",
17+
"outputDirectory",
18+
"basePath",
19+
"exclude",
20+
"properties",
21+
"minClientVersion",
22+
"msBuildVersion",
23+
"verbosity",
24+
"suffix",
25+
];
26+
27+
withValues.forEach(function (prop) {
28+
var value = options[prop];
29+
if (value) {
30+
args.push("-" + prop);
31+
args.push(value);
32+
}
33+
});
34+
35+
withoutValues.forEach(function (prop) {
36+
var value = options[prop];
37+
if (value) {
38+
args.push("-" + prop);
39+
}
40+
});
41+
42+
args.push("-nopackageanalysis");
43+
args.push("-noninteractive");
44+
45+
return args;
4646
};
4747

48-
exports.push = function(nupkg, options) {
49-
var args = ['push', nupkg];
48+
exports.push = function (nupkg, options) {
49+
var args = ["push", nupkg];
5050

51-
var withValues = [
52-
'source',
53-
'apiKey',
54-
'timeout',
55-
'configFile',
56-
'verbosity'
57-
];
51+
var withValues = ["source", "apiKey", "timeout", "configFile", "verbosity"];
5852

59-
withValues.forEach(function(prop) {
60-
var value = options[prop];
61-
if(value) {
62-
args.push('-' + prop);
63-
args.push(value);
64-
}
65-
});
53+
withValues.forEach(function (prop) {
54+
var value = options[prop];
55+
if (value) {
56+
args.push("-" + prop);
57+
args.push(value);
58+
}
59+
});
6660

67-
args.push('-noninteractive');
61+
args.push("-noninteractive");
6862

69-
return args;
63+
return args;
7064
};
7165

72-
exports.restore = function(nupkg, options) {
73-
var args = ['restore', nupkg];
74-
75-
var withValues = [
76-
'source',
77-
'configFile',
78-
'packagesDirectory',
79-
'solutionDirectory',
80-
'msBuildVersion',
81-
'verbosity'
82-
];
83-
84-
var withoutValues = [
85-
'noCache',
86-
'requireConsent',
87-
'disableParallelProcessing'
88-
];
89-
90-
withValues.forEach(function(prop) {
91-
var value = options[prop];
92-
if(value) {
93-
args.push('-' + prop);
94-
args.push(value);
95-
}
96-
});
97-
98-
withoutValues.forEach(function(prop) {
99-
var value = options[prop];
100-
if(value) {
101-
args.push('-' + prop);
102-
}
103-
});
104-
105-
args.push('-noninteractive');
106-
107-
return args;
66+
exports.restore = function (nupkg, options) {
67+
var args = ["restore", nupkg];
68+
69+
var withValues = [
70+
"source",
71+
"configFile",
72+
"packagesDirectory",
73+
"solutionDirectory",
74+
"msBuildVersion",
75+
"verbosity",
76+
];
77+
78+
var withoutValues = [
79+
"noCache",
80+
"requireConsent",
81+
"disableParallelProcessing",
82+
];
83+
84+
withValues.forEach(function (prop) {
85+
var value = options[prop];
86+
if (value) {
87+
args.push("-" + prop);
88+
args.push(value);
89+
}
90+
});
91+
92+
withoutValues.forEach(function (prop) {
93+
var value = options[prop];
94+
if (value) {
95+
args.push("-" + prop);
96+
}
97+
});
98+
99+
args.push("-noninteractive");
100+
101+
return args;
108102
};

lib/pack.js

Lines changed: 67 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,80 +1,84 @@
1-
'use strict';
2-
3-
var cproc = require('child_process');
4-
var through = require('through2');
5-
var fs = require('fs-extra');
6-
var log = require('fancy-log');
7-
var PluginError = require('plugin-error');
8-
var argsFor = require('./argsFor');
9-
var validFor = require('./validFor');
10-
var path = require('path');
11-
var File = require('vinyl');
12-
13-
module.exports = function(options) {
14-
options = options || {};
15-
options.nuget = options.nuget || './nuget.exe';
16-
options.outputDirectory = options.outputDirectory || './.gulp-nuget';
17-
options.maxBuffer = options.maxBuffer || 200*1024;
18-
19-
return through.obj(function(file, encoding, done) {
20-
if(!validFor.pack(file)) {
21-
return done(null, file);
22-
}
23-
24-
var self = this;
25-
var args = argsFor.pack(file.path, options);
26-
var opts = { maxBuffer: options.maxBuffer };
27-
28-
fs.mkdirs(options.outputDirectory, function(err) {
29-
if(err) throw new PluginError('gulp-nuget', err);
30-
31-
cproc.execFile(options.nuget, args, opts, function(err, stdout) {
32-
if(err) throw new PluginError('gulp-nuget', err);
33-
34-
log(stdout.trim());
35-
36-
var files = findNupkgs(stdout);
37-
pushFiles.call(self, files, done);
38-
});
39-
40-
});
41-
});
1+
"use strict";
2+
3+
var cproc = require("child_process");
4+
var through = require("through2");
5+
var fs = require("fs-extra");
6+
var log = require("fancy-log");
7+
var PluginError = require("plugin-error");
8+
var argsFor = require("./argsFor");
9+
var validFor = require("./validFor");
10+
var path = require("path");
11+
var File = require("vinyl");
12+
13+
module.exports = function (options) {
14+
options = options || {};
15+
options.nuget = options.nuget || "./nuget.exe";
16+
options.outputDirectory = options.outputDirectory || "./.gulp-nuget";
17+
options.maxBuffer = options.maxBuffer || 200 * 1024;
18+
19+
return through.obj(function (file, encoding, done) {
20+
if (!validFor.pack(file)) {
21+
return done(null, file);
22+
}
23+
24+
var self = this;
25+
var args = argsFor.pack(file.path, options);
26+
var opts = { maxBuffer: options.maxBuffer };
27+
28+
fs.mkdirs(options.outputDirectory, function (err) {
29+
if (err) throw new PluginError("gulp-nuget", err);
30+
31+
cproc.execFile(options.nuget, args, opts, function (err, stdout) {
32+
if (err) throw new PluginError("gulp-nuget", err);
33+
34+
log(stdout.trim());
35+
36+
var files = findNupkgs(stdout);
37+
pushFiles.call(self, files, done);
38+
});
39+
});
40+
});
4241
};
4342

4443
function pushFiles(files, done) {
45-
var self = this;
46-
47-
files.forEach(function(file, index) {
48-
fs.readFile(file, function(err, data) {
49-
if(err) throw new PluginError('gulp-nuget', err);
50-
51-
self.push(new File({
52-
base: path.dirname(file),
53-
path: file,
54-
contents: data
55-
}));
56-
57-
if((index + 1) === files.length) {
58-
fs.remove('./.gulp-nuget', done);
59-
}
60-
});
61-
});
44+
var self = this;
45+
46+
files.forEach(function (file, index) {
47+
fs.readFile(file, function (err, data) {
48+
if (err) throw new PluginError("gulp-nuget", err);
49+
50+
self.push(
51+
new File({
52+
base: path.dirname(file),
53+
path: file,
54+
contents: data,
55+
})
56+
);
57+
58+
if (index + 1 === files.length) {
59+
fs.remove("./.gulp-nuget", done);
60+
}
61+
});
62+
});
6263
}
6364

6465
function findNupkgs(stdout) {
6566
var matches = [];
66-
var nupkg = new RegExp('[\'"„“](.+\.nupkg)[\'"”]', 'ig');
67+
var nupkg = new RegExp("['\"„“](.+.nupkg)['\"”]", "ig");
6768

6869
var match = nupkg.exec(stdout);
6970

70-
while(match != null) {
71+
while (match != null) {
7172
matches.push(match[1]);
7273
match = nupkg.exec(stdout);
7374
}
7475

75-
if(!matches || !matches.length) {
76-
throw new PluginError('gulp-nuget', 'Could not detect any output .nupkg files from nuget.');
76+
if (!matches || !matches.length) {
77+
throw new PluginError(
78+
"gulp-nuget",
79+
"Could not detect any output .nupkg files from nuget."
80+
);
7781
}
7882

7983
return matches;
80-
};
84+
}

0 commit comments

Comments
 (0)