Skip to content

Commit 8acc62a

Browse files
committed
_
Signed-off-by: Sora Morimoto <[email protected]>
1 parent 2ad03dc commit 8acc62a

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

src/commands/generate-templates/templates-gen-process.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import path from "node:path";
2+
import url from "node:url";
23
import { FileSystem } from "../../util/file-system.js";
3-
import { __dirname } from "../../util/file-system.js";
44
import { Logger } from "../../util/logger.js";
55
import { TemplatesGenConfig } from "./configuration.js";
66

7+
const __dirname = path.dirname(url.fileURLToPath(import.meta.url));
8+
79
class TemplatesGenProcess {
810
/**
911
* @type {TemplatesGenConfig}

src/templates-worker.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { resolve } from "node:path";
22
import path from "node:path";
3+
import url from "node:url";
34
import * as Eta from "eta";
45
import _ from "lodash";
5-
import { __dirname } from "./util/file-system.js";
66

77
class TemplatesWorker {
88
/**
@@ -35,6 +35,7 @@ class TemplatesWorker {
3535
* @returns {CodeGenConfig.templatePaths}
3636
*/
3737
getTemplatePaths = (config) => {
38+
const __dirname = path.dirname(url.fileURLToPath(import.meta.url));
3839
const baseTemplatesPath = resolve(__dirname, "../templates/base");
3940
const defaultTemplatesPath = resolve(__dirname, "../templates/default");
4041
const modularTemplatesPath = resolve(__dirname, "../templates/modular");

src/util/file-system.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@ import url from "node:url";
44
import _ from "lodash";
55
import { Logger } from "./logger.js";
66

7-
const __filename = url.fileURLToPath(import.meta.url);
8-
const __dirname = dirname(__filename);
9-
107
const FILE_PREFIX = `/* eslint-disable */
118
/* tslint:disable */
129
/*
@@ -87,11 +84,12 @@ class FileSystem {
8784
};
8885

8986
createFile = ({ path, fileName, content, withPrefix }) => {
87+
const __dirname = dirname(url.fileURLToPath(import.meta.url));
9088
const absolutePath = resolve(__dirname, path, `./${fileName}`);
9189
const fileContent = `${withPrefix ? FILE_PREFIX : ""}${content}`;
9290

9391
return fs.writeFileSync(absolutePath, fileContent, _.noop);
9492
};
9593
}
9694

97-
export { FileSystem, __dirname };
95+
export { FileSystem };

0 commit comments

Comments
 (0)