mirror of
https://github.com/jakejarvis/jakejarvis.git
synced 2025-12-01 10:03:50 -05:00
🐦 ➡️ 🦣
This commit is contained in:
12
cli/build.js
12
cli/build.js
@@ -1,5 +1,5 @@
|
||||
import path from "path";
|
||||
import fs from "fs/promises";
|
||||
import { writeFile, stat } from "fs/promises";
|
||||
import cpy from "cpy";
|
||||
import mkdirp from "mkdirp";
|
||||
import { transformFileSync } from "@babel/core";
|
||||
@@ -28,7 +28,7 @@ const { code: babelCode } = transformFileSync(inputFile, {
|
||||
await temporaryDirectoryTask(async (tempPath) => {
|
||||
// save babel-ified code above to a temporary file -- unfortunately, we can't pipe this code directly into to ncc
|
||||
const babelFile = path.join(tempPath, "index.cjs");
|
||||
await fs.writeFile(babelFile, babelCode);
|
||||
await writeFile(babelFile, babelCode);
|
||||
|
||||
// hacky warning: ncc needs the node_modules we want to bundle next to the input file, so copy them from here
|
||||
await cpy("node_modules/**", path.join(tempPath, "node_modules"));
|
||||
@@ -46,14 +46,14 @@ await temporaryDirectoryTask(async (tempPath) => {
|
||||
|
||||
// write final build to ./dist and make it executable
|
||||
await Promise.all([
|
||||
fs.writeFile(path.join(outputDir, "index.cjs"), code, { mode: 0o755 }),
|
||||
writeFile(path.join(outputDir, "index.cjs"), code, { mode: 0o755 }),
|
||||
// TODO: figure out if bundling this script from 'open' module is really necessary?
|
||||
// https://linux.die.net/man/1/xdg-open
|
||||
fs.writeFile(path.join(outputDir, "xdg-open"), assets["xdg-open"].source, { mode: 0o755 }),
|
||||
writeFile(path.join(outputDir, "xdg-open"), assets["xdg-open"].source, { mode: 0o755 }),
|
||||
]);
|
||||
});
|
||||
|
||||
// quick logging of resulting filesizes
|
||||
console.log("🎉 Success!");
|
||||
console.log(`dist/index.cjs\t${prettyBytes((await fs.stat(path.join(outputDir, "index.cjs"))).size)}`);
|
||||
console.log(`dist/xdg-open\t${prettyBytes((await fs.stat(path.join(outputDir, "xdg-open"))).size)}`);
|
||||
console.log(`dist/index.cjs\t${prettyBytes((await stat(path.join(outputDir, "index.cjs"))).size)}`);
|
||||
console.log(`dist/xdg-open\t${prettyBytes((await stat(path.join(outputDir, "xdg-open"))).size)}`);
|
||||
|
||||
Reference in New Issue
Block a user