This repository has been archived by the owner on Sep 19, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
nuget-restore.js
37 lines (37 loc) · 1.54 KB
/
nuget-restore.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
"use strict";
(function () {
const chalk = requireModule("ansi-colors"), env = requireModule("env"), gulp = requireModule("gulp"), debug = requireModule("debug")(__filename), nugetRestore = requireModule("./gulp-nuget-restore"), promisify = requireModule("promisify-stream"), resolveMasks = requireModule("resolve-masks"), tryDo = requireModule("try-do"), findLocalNuget = requireModule("find-local-nuget");
const myTasks = ["nuget-restore"], myVars = [
"DOTNET_CORE",
"BUILD_INCLUDE",
"BUILD_EXCLUDE",
"BUILD_ADDITIONAL_EXCLUDE",
"RESTORE_RETRIES"
];
env.associate(myVars, myTasks);
gulp.task("nuget-restore", "Restores all nuget packages in all solutions", ["install-tools"], tryRestore);
async function tryRestore() {
await tryDo(restore, "RESTORE_RETRIES", e => console.error(chalk.red(`Clean fails: ${e}`)));
}
async function restore() {
const allDNC = env.resolveFlag("DOTNET_CORE"), slnMasks = resolveMasks("BUILD_INCLUDE", ["BUILD_EXCLUDE", "BUILD_EXTRA_EXCLUDE"]);
debug({
allDNC,
slnMasks,
cwd: process.cwd()
});
const options = {
debug: false
};
const start = allDNC
? () => Promise.resolve()
: findLocalNuget;
if (allDNC) {
options.nuget = "dotnet";
}
await start();
await promisify(gulp.src(slnMasks, { allowEmpty: true })
.pipe(nugetRestore(options)));
debug("nuget restore complete!");
}
})();