-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmake.js
21 lines (13 loc) · 949 Bytes
/
make.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import { sqlmacro } from 'sqlmacro';
import { readFile, writeFile } from 'fs/promises';
async function asyncProc(templateFilename, bodyFilename, outputFilename ){
const template = (await readFile( templateFilename, 'utf-8' ));
const body = (await readFile( bodyFilename, 'utf-8' ));
const output = sqlmacro([template])(body);
await writeFile( outputFilename, output, 'utf-8' );
return 'succeeded to compile modules';
}
asyncProc( 'index.template.cjs', 'index.js', 'index.cjs' ).then(v=>console.log(v)).catch(v=>console.error(v));
asyncProc( 'index.template.mjs', 'index.js', 'index.mjs' ).then(v=>console.log(v)).catch(v=>console.error(v));
asyncProc( 'index.test.template.cjs', 'index.test.js', 'index.test.cjs' ).then(v=>console.log(v)).catch(v=>console.error(v));
asyncProc( 'index.test.template.mjs', 'index.test.js', 'index.test.mjs' ).then(v=>console.log(v)).catch(v=>console.error(v));