Skip to content

Commit

Permalink
cli bash replaced with node (#285)
Browse files Browse the repository at this point in the history
  • Loading branch information
volovyks authored Nov 8, 2022
1 parent aecc58b commit 85c2f6c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 15 deletions.
14 changes: 8 additions & 6 deletions lib/cli/cli.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 9 additions & 9 deletions src/cli/cli.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env node

import fs from "fs/promises";
import fs from "fs";
import path, { basename, dirname } from "path";

import { nodeResolve } from "@rollup/plugin-node-resolve";
Expand Down Expand Up @@ -64,9 +64,11 @@ export async function buildCom(
}

signale.await(`Creating ${TARGET_DIR} directory...`);
await executeCommand(`mkdir -p ${TARGET_DIR}`, verbose);
if (!fs.existsSync(TARGET_DIR)) {
fs.mkdirSync(TARGET_DIR, {});
}

signal.await(`Validating ${source} contract...`);
signal.await(`Validatig ${source} contract...`);
if (!await validateContract(source, verbose)) {
process.exit(1);
}
Expand Down Expand Up @@ -160,7 +162,7 @@ async function createMethodsHeaderFile(rollupTarget: string, verbose = false) {
""
);

await fs.writeFile(`${buildPath}/methods.h`, methods);
fs.writeFileSync(`${buildPath}/methods.h`, methods);
}

async function createWasmContract(
Expand All @@ -184,11 +186,9 @@ async function createWasmContract(
const LIBS = `-lm`;

// copying builder.c file to the build folder
await executeCommand(
`cp ${ORIGINAL_BUILDER_PATH} ${NEW_BUILDER_PATH}`,
verbose
);
await executeCommand(`mv ${qjscTarget} build/code.h`, verbose);
fs.cpSync(ORIGINAL_BUILDER_PATH, NEW_BUILDER_PATH);

fs.renameSync(qjscTarget, "build/code.h");

await executeCommand(
`${CC} --target=wasm32-wasi -nostartfiles -Oz -flto ${DEFS} ${INCLUDES} ${SOURCES} ${LIBS} -Wl,--no-entry -Wl,--allow-undefined -Wl,-z,stack-size=${256 * 1024
Expand Down

0 comments on commit 85c2f6c

Please sign in to comment.