This repository was archived by the owner on Jun 5, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbootstrap.js
More file actions
61 lines (44 loc) · 1.61 KB
/
bootstrap.js
File metadata and controls
61 lines (44 loc) · 1.61 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
var async = alchemy.use('async'),
path = alchemy.use('path'),
fs = alchemy.use('fs'),
// Where the original files are located
source = path.resolve(__dirname, 'source'),
// Where the files will be stored and allowed to be overwritten
target = path.resolve(PATH_TEMP, 'stylesheets'),
// Another copy where they're meant to be kept as-is
targetOri = path.resolve(PATH_TEMP, 'stylesheets', 'original');
// Before copying any other stylesheet files, put the originals first
alchemy.sputnik.beforeSerial('stylesheets', function(callback) {
// Read in all the subdirectories in the source
fs.readdir(source, function(err, files) {
var tasks = {}, file, i;
// If no files are present, call the callback immediately
if (files.length === 0) {
return callback();
}
for (i = 0; i < files.length; i++) {
file = files[i];
// IIFE
(function(sourcepath, targetpath, targetorigin) {
// Queue the function for async
tasks[file] = function(async_callback) {
// Copy the subdir
alchemy.copyDir(sourcepath, targetpath, function(err) {
async_callback();
});
// Also copy to the origin folder, where they're not meant
// to be overwritten, but don't let anything wait for it
alchemy.copyDir(sourcepath, targetorigin, function(err) {});
};
}(
path.resolve(source, file), // Source
path.resolve(target, file), // Target
path.resolve(targetOri, file)) // Target original copy
);
}
// Execute all the set tasks in parallel using async
async.parallel(tasks, function(err, results) {
callback();
});
});
});