forked from requirejs/r.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
copydist.js
executable file
·33 lines (28 loc) · 953 Bytes
/
copydist.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
#!/usr/bin/env node
var fs = require('fs'),
stamp = (new Date()).toUTCString(),
exec = require('child_process').exec,
distFileName = 'dist/r.js',
count = 0,
contents;
exec('node dist.js',
function (error, stdout, stderr) {
if (error) {
console.error('ERROR: ' + error);
} else {
fs.writeFileSync(distFileName, fs.readFileSync('r.js', 'utf8'), 'utf8');
contents = fs.readFileSync(distFileName, 'utf8')
.replace(/\d\.\d\.\d+(\+|[a-z]+)?/g, function (match) {
//Only do date insertion twice at the top of the file.
count += 1;
if (count < 3) {
return match + ' ' + stamp;
} else {
return match;
}
}
);
fs.writeFileSync(distFileName, contents, 'utf8');
}
}
);