-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathgulpfile.js
89 lines (75 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
var gulp = require('gulp');
var del = require('del');
var jasmine = require('gulp-jasmine-phantom');
// Paths
var environment;
var repoRoot = __dirname + '/';
var npmRoot = repoRoot + 'node_modules';
var govukToolkitRoot = npmRoot + '/govuk_frontend_toolkit';
var govukToolkitAppFolder = repoRoot + 'pages_builder/govuk_frontend_toolkit';
var govukElementsRoot = npmRoot + '/govuk-elements-sass';
var govukElementsRootFolder = repoRoot + 'pages_builder/govuk-elements-sass'
// Clean directories
gulp.task('clean', function () {
return del([
'pages/*',
'pages_builder/govuk_frontend_toolkit',
'pages_builder/govuk-elements-sass',
]);
});
// Copy files
function copyFactory(resourceName, sourceFolder, targetFolder) {
return function() {
return gulp
.src(sourceFolder + "/**/*", { base: sourceFolder })
.pipe(gulp.dest(targetFolder))
.on('end', function () {
console.log('📂 Copied ' + resourceName);
});
};
}
gulp.task(
'copy:govuk_frontend_toolkit',
copyFactory(
"GOV.UK frontend toolkit stuff",
govukToolkitRoot,
govukToolkitAppFolder
)
);
gulp.task(
'copy:govuk-elements-sass',
copyFactory(
"GOV.UK Elements",
govukElementsRoot,
govukElementsRootFolder
)
);
gulp.task('copy',
gulp.parallel(
'copy:govuk_frontend_toolkit', 'copy:govuk-elements-sass'
)
);
// Test
gulp.task('test', function () {
var manifest = require(repoRoot + 'spec/javascripts/manifest.js').manifest;
manifest.support = manifest.support.map(function (val) {
return val.replace(/^(\.\.\/)*/, function (match) {
if (match === '../../../') {
return '';
}
else {
return 'spec/javascripts/support/'
}
});
});
manifest.test = manifest.test.map(function (val) {
return val.replace(/^\.\.\//, 'spec/javascripts/');
});
return gulp.src(manifest.test)
.pipe(jasmine({
'jasmine': '3.1',
'integration': true,
'abortOnFail': true,
'vendor': manifest.support
}));
});