forked from fluffynuts/NUnit.StaticExpect
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
66 lines (63 loc) · 1.99 KB
/
gulpfile.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
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
/*
* Welcome new user! To get started, ensure that you have copied
* the start/packages.json alongside this file, in the root of your repo.
* Then do:
* > npm install
* After that, you can:
* > node node_modules/gulp/bin/gulp.js
* OR, install gulp globally:
* > npm install -g gulp
* and then you can just:
* > gulp
* I HIGHLY recommend using the first method at your build server
*
* To add or change tasks, do so one task per file in the gulp-tasks folder
*/
var fs = require('fs'),
debug = require('debug')('gulpfile'),
gulpTasksFolder = 'gulp-tasks'; // if you cloned elsewhere, you'll need to modify this
requireModule = global.requireModule = function(module) {
var modulePath = ['.', gulpTasksFolder, 'modules', module].join('/');
return require(modulePath);
},
importNpmTasks = requireModule("import-npm-tasks");
if (!fs.existsSync('package.json')) {
['You\'re nearly there!',
'Please copy the package.json from the start folder alongside your gulpfile.js',
'then run `npm install` to install the required packages'].forEach(function(s) {
console.log(s);
});
process.exit(1);
}
try {
importNpmTasks();
var requireDir = require('require-dir');
requireDir('gulp-tasks');
['override-tasks', 'local-tasks'].forEach(function(dirname) {
if (fs.existsSync(dirname)) {
requireDir(dirname);
}
});
} catch (e) {
if (shouldDump(e)) {
console.error(e);
} else {
if (!process.env.DEBUG) {
console.log("Error occurred. For more info, set the DEBUG environment variable (eg set DEBUG=*).")
}
}
process.exit(1);
}
function shouldDump(e) {
return process.env.ALWAYS_DUMP_GULP_ERRORS || probablyNotReportedByGulp(e);
}
function probablyNotReportedByGulp(e) {
var message = (e || "").toString().toLowerCase();
return [
"cannot find module",
"referenceerror",
"syntaxerror"
].reduce((acc, cur) => {
return acc || message.indexOf(cur) > -1;
}, false);
}