Skip to content

Commit

Permalink
fix: fix output path
Browse files Browse the repository at this point in the history
  • Loading branch information
shoma-mano committed Sep 5, 2024
1 parent 69a7aaf commit e4cea4e
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
},
"scripts": {
"build": "unbuild",
"release": "unbuild && changelogen --release --push --publish"
"release": "changelogen --release --push --publish"
},
"files": [
"dist"
Expand All @@ -32,5 +32,8 @@
"changelogen": "^0.5.5",
"prettier": "^3.3.3",
"unbuild": "^2.0.0"
},
"dependencies": {
"get-caller-file": "^2.0.5"
}
}
10 changes: 10 additions & 0 deletions pnpm-lock.yaml

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

10 changes: 6 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import { basename, join } from "path";
import type { ECSTaskDefinition } from "./interface";
import { writeFileSync } from "fs";

import getCallerFile from "get-caller-file";
export const defineTaskDefinition = (
props: ECSTaskDefinition,
distPath?: string,
) => {
const fileName = basename(__filename).replace(".ts", ".json");
distPath = distPath ?? join(__dirname, fileName);
const callerFile = getCallerFile();
if (!callerFile) {
throw new Error("Cannot find caller file");
}
distPath = distPath ?? (callerFile.replace(".ts", ".json") as string);
const json = JSON.stringify(props, null, 2);
writeFileSync(distPath, json);
};

0 comments on commit e4cea4e

Please sign in to comment.