forked from Incapture/ROC
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.js
More file actions
77 lines (64 loc) · 1.88 KB
/
gulpfile.js
File metadata and controls
77 lines (64 loc) · 1.88 KB
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
66
67
68
69
70
71
72
73
74
75
76
"use strict";
var gulp = require("gulp"),
del = require("del"),
fs = require("fs"),
runSequence = require("run-sequence"),
yargs = require("yargs"),
argv,
location,
prModules,
copyModules = true;
argv = yargs.argv;
gulp.task("clean-private-npm", function() {
return del("node_modules_incapture");
});
gulp.task("build-private-npm", function() {
var stream;
for (var idx = 0; idx < prModules.length; idx++) {
stream += gulp.src(location + prModules[idx] + "/**/*")
.pipe(gulp.dest("node_modules_incapture/" + prModules[idx]));
}
return stream;
});
// copy latest RaptureJS modules from specified location (NOTE: this task is for non-Docker local environments ONLY)
gulp.task("rapturejs-latest", function() {
if (!argv.loc)
console.log("ERROR: Please specify the location for RaptureJS.\n(E.g. --loc ~/RaptureJS)");
else {
location = argv.loc[argv.loc.length - 1] === "/" ? argv.loc : argv.loc + "/";
if (!argv.modules)
console.log("ERROR: Please specify the private modules that you wish to install from RaptureJS.\n(E.g. --modules '[\"core-auth\"]'");
else {
prModules = JSON.parse(argv.modules)
if (Object.prototype.toString.call(prModules) === "[object Array]" ) {
// check if RaptureJS exists at specified location
if (!(folderExists(location)))
console.log("ERROR: RaptureJS not found at the specified location. Please try again.");
else {
for (var idx = 0; idx < prModules.length; idx++) {
if (!(folderExists(location + prModules[idx]))) {
console.log("ERROR: module " + prModules[idx] + " not found in RaptureJS.");
copyModules = false;
break;
}
}
if (copyModules) {
runSequence(
"clean-private-npm",
"build-private-npm"
);
}
}
}
}
}
});
function folderExists(path) {
try {
fs.accessSync(path)
return true;
}
catch(e) {
return false;
}
}