Skip to content

Commit

Permalink
Merge branch 'master' of github.com:mckn/gulp-nuget
Browse files Browse the repository at this point in the history
  • Loading branch information
mckn committed Apr 4, 2022
2 parents 893c84b + 4bde481 commit 187898c
Show file tree
Hide file tree
Showing 7 changed files with 151 additions and 11 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,12 @@ var options = {
verbosity: 'normal',
build: true,
symbols: true,
symbolPackageFormat: "snupkg",
excludeEmptyDirectories: true,
includeReferencedProjects: true,
noDefaultExcludes: true,
tool: true,
interactive: true // Override the default nonInteractive option
};

var stream = nuget.pack(options);
Expand Down Expand Up @@ -146,6 +148,7 @@ var options = {
timeout: '300',
configFile: '%AppData%/NuGet/NuGet.config',
verbosity: 'normal',
interactive: true // Override the default nonInteractive option
};

var stream = nuget.push(options);
Expand Down Expand Up @@ -208,7 +211,8 @@ var options = {
verbosity: 'normal',
noCache: true,
requireConsent: true,
disableParallelProcessing: true
disableParallelProcessing: true,
interactive: true // Override the default nonInteractive option
};

var stream = nuget.restore(options);
Expand Down
17 changes: 12 additions & 5 deletions lib/argsFor.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ exports.pack = function (nuspecFile, options) {
"excludeEmptyDirectories",
"includeReferencedProjects",
"noDefaultExcludes",
"tool",
"tool"
];

var withValues = [
Expand All @@ -22,6 +22,7 @@ exports.pack = function (nuspecFile, options) {
"msBuildVersion",
"verbosity",
"suffix",
"symbolPackageFormat"
];

withValues.forEach(function (prop) {
Expand All @@ -40,7 +41,9 @@ exports.pack = function (nuspecFile, options) {
});

args.push("-nopackageanalysis");
args.push("-noninteractive");
if (!options["interactive"]) {
args.push("-noninteractive");
}

return args;
};
Expand All @@ -58,7 +61,9 @@ exports.push = function (nupkg, options) {
}
});

args.push("-noninteractive");
if (!options["interactive"]) {
args.push("-noninteractive");
}

return args;
};
Expand Down Expand Up @@ -96,7 +101,9 @@ exports.restore = function (nupkg, options) {
}
});

args.push("-noninteractive");

if (!options["interactive"]) {
args.push("-noninteractive");
}

return args;
};
4 changes: 2 additions & 2 deletions lib/pack.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ function pushFiles(files, done) {

function findNupkgs(stdout) {
var matches = [];
var nupkg = new RegExp("['\"„“](.+.nupkg)['\"”]", "ig");
var nupkg = new RegExp("['\"„“](.+\.s?nupkg)['\"”]", "ig");

var match = nupkg.exec(stdout);

Expand All @@ -76,7 +76,7 @@ function findNupkgs(stdout) {
if (!matches || !matches.length) {
throw new PluginError(
"gulp-nuget",
"Could not detect any output .nupkg files from nuget."
"Could not detect any output .(s)nupkg files from nuget."
);
}

Expand Down
4 changes: 2 additions & 2 deletions lib/validFor.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ exports.restore = function (file) {

exports.push = function (file) {
var msg =
file.path + " is not supported. Supported files for nuget push are: .nupkg";
var regexp = /^(\.nupkg)$/i;
file.path + " is not supported. Supported files for nuget push are: .nupkg, .snupkg";
var regexp = /^(\.s?nupkg)$/i;

return supported(file, regexp, msg);
};
Expand Down
16 changes: 15 additions & 1 deletion test/pack_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ describe("when pushing nuspec file to nuget pack stream", function () {
});
});

describe("and symbols is set in options", function () {
describe("and legacy symbols is set in options", function () {
before(function (done) {
nupkgs = [];
options = { nuget: "nuget", symbols: true };
Expand All @@ -112,4 +112,18 @@ describe("when pushing nuspec file to nuget pack stream", function () {
assert.equal(nupkgs.length, 2);
});
});

describe("and symbols package is set in options", function () {
before(function (done) {
nupkgs = [];
options = { nuget: "nuget", symbols: true, symbolPackageFormat: "snupkg" };
packFile("./test/nuspecs/with-version.nuspec", options, done);
});

it("should create one snupkg package", function() {
assert.equal(nupkgs.length, 2);
});
});


});
90 changes: 90 additions & 0 deletions test/push_symbol_tests.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
"use strict";

var assert = require("chai").assert;
var proxyquire = require("proxyquire");
var File = require("vinyl");
var map = require("vinyl-map");
var cproc = {
execFile: function (file, args, opts, cb) {
this.file = file;
this.args = args;
cb(null, "success");
},
};
var pushStream = proxyquire("../lib/push", { child_process: cproc });

describe("when pushing nuget symbol package to push stream", function () {
var pushedNugetPkg;
var options;
var file;

var processStream = function (done) {
var stream = pushStream(options);

stream.pipe(
map(function (code, filename) {
pushedNugetPkg = {
path: filename,
contents: code,
};
})
);

stream.on("end", done);
stream.write(file);
stream.end();
};

before(function () {
options = {
nuget: "nuget",
source: "http://localhost",
apiKey: "asdfasdfasfd",
};

file = new File({
cwm: "../",
base: "../",
path: "../testing.snupkg",
contents: Buffer.from("testing"),
});
});

describe("and symbol push cmd is mocked", function () {
before(function (done) {
processStream(done);
});

it("should call push cmd mock with correct options", function () {
var expected = [
"push",
"../testing.snupkg",
"-apiKey",
"asdfasdfasfd",
"-source",
"http://localhost",
"-noninteractive",
];

assert.sameMembers(cproc.args, expected);
});

it("should call push cmd mock with correct nuget symbol package path", function () {
assert.deepEqual(cproc.file, "nuget");
});
});

describe("and stream is piped", function () {
before(function (done) {
processStream(done);
});

it("should push nuget symbol package to the next stream", function () {
assert.equal(pushedNugetPkg.path, "../testing.snupkg");
});

it("should push nuget symbol package to the next stream", function () {
assert.equal(pushedNugetPkg.contents.length, 7);
});
});
});
25 changes: 25 additions & 0 deletions test/push_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,31 @@ describe("when pushing nuget package to push stream", function () {
});
});

describe("and push cmd is mocked with override non interactive", function () {
before(function (done) {
options = {
nuget: "nuget",
source: "http://localhost",
apiKey: "asdfasdfasfd",
interactive: true
};
processStream(done);
});

it("should call push cmd mock with correct options (no noninteractive)", function () {
var expected = [
"push",
"../testing.nupkg",
"-apiKey",
"asdfasdfasfd",
"-source",
"http://localhost"
];

assert.sameMembers(cproc.args, expected);
});
});

describe("and stream is piped", function () {
before(function (done) {
processStream(done);
Expand Down

0 comments on commit 187898c

Please sign in to comment.