-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathbuild-examples.js
More file actions
27 lines (24 loc) · 913 Bytes
/
build-examples.js
File metadata and controls
27 lines (24 loc) · 913 Bytes
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
import fs from 'fs';
import path from 'path';
import { fileURLToPath } from 'url';
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const version = JSON.parse(fs.readFileSync(path.join(__dirname, 'package.json'))).version;
fs.mkdirSync(path.join(__dirname, 'dist'));
fs.readdirSync(path.join(__dirname, 'examples'), { withFileTypes: true }).forEach((entry) => {
if (entry.isDirectory()) {
fs.cpSync(
path.resolve(__dirname, 'examples', entry.name),
path.join(__dirname, 'dist', entry.name),
{ recursive: true }
);
} else {
fs.writeFileSync(
path.join(__dirname, 'dist', entry.name),
fs.readFileSync(path.resolve(__dirname, 'examples', entry.name), 'utf8')
.replace(
'"three-raymarcher": "../module.js"',
`"three-raymarcher": "https://cdn.jsdelivr.net/npm/three-raymarcher@${version}/module.js"`,
)
);
}
});