-
Notifications
You must be signed in to change notification settings - Fork 15
/
move-artifacts.js
38 lines (31 loc) · 1.05 KB
/
move-artifacts.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
const path = require('path');
const fs = require('fs-extra');
const globby = require('globby');
const ARTIFACTS_ROOT = path.join(__dirname, 'parcel_sourcemap_node/artifacts');
let artifacts = globby.sync(path.join(ARTIFACTS_ROOT, '*/*.node'));
if (!artifacts.length) {
throw new Error('No artifacts found!');
}
console.log('Moving artifacts...');
for (let artifact of artifacts) {
let stat = fs.statSync(artifact);
if (stat.isFile()) {
let filename = path.basename(artifact);
fs.moveSync(artifact, path.join(ARTIFACTS_ROOT, filename));
console.log('Moved:', filename);
}
}
console.log('Cleaning up artifacts folder...');
let artifactsFolderContent = fs.readdirSync(ARTIFACTS_ROOT);
for (let entry of artifactsFolderContent) {
let fullPath = path.join(ARTIFACTS_ROOT, entry);
if (!fullPath.endsWith('.node')) {
fs.removeSync(fullPath);
console.log('Removed:', fullPath);
}
}
console.log('=== ARTIFACTS ===');
artifactsFolderContent = fs.readdirSync(ARTIFACTS_ROOT);
for (let entry of artifactsFolderContent) {
console.log('-', entry);
}