diff --git a/index.ts b/index.ts index 7c7be04..5e6aec0 100644 --- a/index.ts +++ b/index.ts @@ -20,9 +20,9 @@ import write from "./src/lib/write"; // Generate `build` object const build: Build = {}; - + const path = args.path || "src/build.ts" ; build.version = await version(); - build.timestamp = new Date().toString(); + build.timestamp = new Date().toUTCString(); build.message = args.message || (args.message === "" ? await message() : null); build.git = args.noGit @@ -35,7 +35,7 @@ import write from "./src/lib/write"; }; // Write Build information to file - await write(build); + await write(build, path); console.log(""); signale.success("Saved Build Information"); diff --git a/package.json b/package.json index 0b1dc6b..f7db10d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "angular-build-info", - "version": "2.0.1", + "version": "2.0.2", "description": "🛠 A CLI to generate an easily importable `build.ts` file containing various details about the application build", "main": "index.js", "bin": { diff --git a/src/lib/arguments.ts b/src/lib/arguments.ts index 3dd37c2..1f39406 100644 --- a/src/lib/arguments.ts +++ b/src/lib/arguments.ts @@ -20,6 +20,11 @@ const args = yargs(process.argv) type: "string", description: "Specify a build message", }) + .option("path", { + alias: "p", + type: "string", + description: "Path for build.ts", + }) .option("no-git", { alias: "g", type: "boolean", diff --git a/src/lib/write.ts b/src/lib/write.ts index 7dadb64..00dceab 100644 --- a/src/lib/write.ts +++ b/src/lib/write.ts @@ -15,7 +15,7 @@ const write = async (content: Build, path?: string): Promise => { await fs.writeFile( writePath, "// Build information, automatically generated by `ng-info`\n" + - "const build = " + + "export const build = " + JSON.stringify(content, null, 4).replace( /\"([^(\")"]+)\":/g, "$1:"