forked from Foblex/f-flow
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathanalyze.js
More file actions
37 lines (30 loc) · 1.08 KB
/
Copy pathanalyze.js
File metadata and controls
37 lines (30 loc) · 1.08 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
const fs = require('fs');
const path = require('path');
const { execSync } = require('child_process');
const distPath = path.resolve(__dirname, 'dist/f-flow-portal/browser');
try {
execSync('ng build', { stdio: 'inherit' });
// eslint-disable-next-line no-unused-vars,@typescript-eslint/no-unused-vars
} catch (e) {
process.exit(1);
}
const jsFiles = fs.readdirSync(distPath).filter(f => f.endsWith('.js'));
const mapFiles = fs.readdirSync(distPath).filter(f => f.endsWith('.js.map'));
const paired = jsFiles
.map(js => {
const map = mapFiles.find(m => m.startsWith(js));
return map ? [path.join(distPath, js), path.join(distPath, map)] : null;
})
.filter(Boolean);
if (paired.length === 0) {
process.exit(1);
}
// eslint-disable-next-line no-console
paired.forEach(([js]) => console.log('- ' + path.basename(js)));
try {
const args = paired.map(([js, map]) => `"${js}" "${map}"`).join(' ');
execSync(`npx source-map-explorer ${args}`, { stdio: 'inherit' });
// eslint-disable-next-line no-unused-vars,@typescript-eslint/no-unused-vars
} catch (e) {
process.exit(1);
}