forked from ReactiveX/rxjs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.make-helpers.js
42 lines (36 loc) · 1.14 KB
/
.make-helpers.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
"use strict";
let fs = require('fs-extra');
let path = require('path');
let klawSync = require('klaw-sync');
function cleanSourceMapRoot(mapRoot, sourcesRoot) {
klawSync(mapRoot, {filter: (item) => item.path.endsWith('.js.map')})
.map(f => f.path)
.forEach(fName => {
const sourceMap = fs.readJsonSync(fName);
// Get relative path from map file to source file
sourceMap.sources = sourceMap.sources.map(s => {
const sRel = path.relative(path.parse(fName).dir, path.resolve(path.join(sourcesRoot, s)));
return sRel;
});
delete sourceMap.sourceRoot;
fs.writeJsonSync(fName, sourceMap);
});
}
function copySources(rootDir, packageDir, ignoreMissing) {
// If we are ignoring missing directories, early return when source doesn't exist
if (!fs.existsSync(rootDir)) {
if (ignoreMissing) {
return;
} else {
throw "Source root dir does not exist!";
}
}
// Copy over the CommonJS files
fs.copySync(rootDir, packageDir);
fs.copySync('./LICENSE.txt', packageDir + 'LICENSE.txt');
fs.copySync('./README.md', packageDir + 'README.md');
}
module.exports = {
copySources,
cleanSourceMapRoot
}