Skip to content

Commit

Permalink
simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
mitschabaude committed Jun 20, 2023
1 parent cdfca55 commit 521ce79
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 22 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"make": "make -C ../../.. snarkyjs",
"make:no-types": "npm run clean && make -C ../../.. snarkyjs_no_types",
"bindings": "cd ../../.. && ./scripts/update-snarkyjs-bindings.sh && cd src/lib/snarkyjs",
"build": "rimraf ./src/bindings/compiled/_node_bindings && cp -r src/bindings/compiled/node_bindings src/bindings/compiled/_node_bindings && rimraf ./dist/node && npx tsc -p tsconfig.node.json && node src/build/copy-to-dist.js && node src/build/buildNode.js",
"build": "node src/build/copy-artifacts.js && rimraf ./dist/node && npm run dev && node src/build/buildNode.js",
"build:test": "npx tsc -p tsconfig.test.json && cp src/snarky.d.ts dist/node/snarky.d.ts",
"build:node": "npm run build",
"build:web": "rimraf ./dist/web && node src/build/buildWeb.js",
Expand Down
8 changes: 8 additions & 0 deletions src/build/copy-artifacts.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// copy some files from /src to /dist/node that tsc doesn't copy because we have .d.ts files for them
import { copyFromTo } from './utils.js';

await copyFromTo(
['src/bindings/compiled/node_bindings/'],
'node_bindings',
'_node_bindings'
);
28 changes: 7 additions & 21 deletions src/build/copy-to-dist.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,8 @@
// copy some files from /src to /dist/node that tsc doesn't copy because
// we have .d.ts files for them
import fse from 'fs-extra';
// copy some files from /src to /dist/node that tsc doesn't copy because we have .d.ts files for them
import { copyFromTo } from './utils.js';

let files = ['src/snarky.d.ts', 'src/bindings/compiled/_node_bindings'];

await copyToDist(files);

async function copyToDist(files) {
let promises = [];
for (let source of files) {
let target = source.replace('src/', 'dist/node/');
promises.push(
fse.copy(source, target, {
recursive: true,
overwrite: true,
dereference: true,
})
);
}
await Promise.all(promises);
}
await copyFromTo(
['src/snarky.d.ts', 'src/bindings/compiled/_node_bindings'],
'src',
'dist/node'
);
18 changes: 18 additions & 0 deletions src/build/utils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import fse from 'fs-extra';

export { copyFromTo };

async function copyFromTo(files, srcDir = undefined, targetDir = undefined) {
let promises = [];
for (let source of files) {
let target = source.replace(`${srcDir}/`, `${targetDir}/`);
promises.push(
fse.copy(source, target, {
recursive: true,
overwrite: true,
dereference: true,
})
);
}
await Promise.all(promises);
}

0 comments on commit 521ce79

Please sign in to comment.