-
Notifications
You must be signed in to change notification settings - Fork 2k
/
Copy pathbuild-deno.js
35 lines (27 loc) · 998 Bytes
/
build-deno.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
'use strict';
const fs = require('fs');
const path = require('path');
const babel = require('@babel/core');
const {
writeGeneratedFile,
readdirRecursive,
showDirStats,
} = require('./utils.js');
if (require.main === module) {
fs.rmSync('./denoDist', { recursive: true, force: true });
fs.mkdirSync('./denoDist');
const srcFiles = readdirRecursive('./src', { ignoreDir: /^__.*__$/ });
for (const filepath of srcFiles) {
const srcPath = path.join('./src', filepath);
const destPath = path.join('./denoDist', filepath);
fs.mkdirSync(path.dirname(destPath), { recursive: true });
if (filepath.endsWith('.ts')) {
const options = { babelrc: false, configFile: './.babelrc-deno.json' };
const output = babel.transformFileSync(srcPath, options).code + '\n';
writeGeneratedFile(destPath, output);
}
}
fs.copyFileSync('./LICENSE', './denoDist/LICENSE');
fs.copyFileSync('./README.md', './denoDist/README.md');
showDirStats('./denoDist');
}