-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.js
More file actions
27 lines (23 loc) · 829 Bytes
/
Copy pathbuild.js
File metadata and controls
27 lines (23 loc) · 829 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 { promisify } from 'util'
import j2s from 'json2server'
import pkg from '../package.json'
const replace = j2s.methods.replace
const writeFile = promisify(fs.writeFile)
async function main() {
serverJson.root.$ = { name: pkg.name, version: pkg.version }
configJson.mountpath = `/api/v${pkg.version.split('.').shift()}`;
configJson.loglevel = 2;
configJson.moduledir = 'modules';
delete pkg.devDependencies;
delete pkg.scripts;
delete pkg.nyc;
delete pkg.babel;
pkg.scripts = { start: './node_modules/.bin/json2server' };
await Promise.all([
writeFile('dist/server.json', JSON.stringify(serverJson, undefined, 2)),
writeFile('dist/j2s.json', JSON.stringify(configJson, undefined, 2)),
writeFile('dist/package.json', JSON.stringify(pkg, undefined, 2)),
]);
}
main();