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.ts
65 lines (61 loc) · 1.74 KB
/
nuget-restore.ts
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
(function () {
const
chalk = requireModule<AnsiColors>("ansi-colors"),
env = requireModule<Env>("env"),
gulp = requireModule<Env>("gulp"),
debug = requireModule<DebugFactory>("debug")(__filename),
nugetRestore = requireModule<GulpNugetRestore>("./gulp-nuget-restore"),
promisify = requireModule<PromisifyStream>("promisify-stream"),
resolveMasks = requireModule<ResolveMasks>("resolve-masks"),
tryDo = requireModule<TryDo<any>>("try-do"),
findLocalNuget = requireModule<FindLocalNuget>("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
} as NugetRestoreOptions;
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!");
}
})();