UNPKG

one

Version:

One is a React framework for web, iOS, and Android apps.

45 lines (42 loc) • 1.91 kB
import { dirname, join } from "path"; import FSExtra from "fs-extra"; import { toAbsolute } from "./toAbsolute.native.js"; var buildOutputPointerPath = join("node_modules", ".cache", "one", "build-pointer.json"); async function writeBuildOutputPointer(outDir) { try { var pointerPath = toAbsolute(buildOutputPointerPath); await FSExtra.ensureDir(dirname(pointerPath)); await FSExtra.writeJSON(pointerPath, { outDir }); } catch (err) { console.warn(`[one build] could not write build-output pointer (${buildOutputPointerPath}). \`one serve\` will fall back to 'dist/' unless you pass --outDir.`, err instanceof Error ? err.message : err); } } async function resolveServeOutDir(outDir) { if (outDir) { return outDir; } if (FSExtra.existsSync("buildInfo.json")) { return "."; } var pointer; try { pointer = await FSExtra.readJSON(buildOutputPointerPath); } catch (err) { if ((err === null || err === void 0 ? void 0 : err.code) && err.code !== "ENOENT") { var _err_message; console.warn(`[one serve] could not read build-output pointer (${buildOutputPointerPath}):`, (_err_message = err.message) !== null && _err_message !== void 0 ? _err_message : err); } } if (pointer === null || pointer === void 0 ? void 0 : pointer.outDir) { if (await FSExtra.pathExists(join(pointer.outDir, "buildInfo.json"))) { return pointer.outDir; } console.warn(`[one serve] build-pointer.json points to '${pointer.outDir}/' but no buildInfo.json was found there. run \`one build\` to refresh the marker.`); } if (!FSExtra.existsSync("dist/buildInfo.json")) { console.warn(`[one serve] no build-output pointer and no 'dist/buildInfo.json'. did \`one build\` run from this cwd? pass --outDir to point at the build output.`); } return "dist"; } export { buildOutputPointerPath, resolveServeOutDir, writeBuildOutputPointer }; //# sourceMappingURL=buildOutputPointer.native.js.map