Skip to content

Commit 9543fab

Browse files
committed
Fix build warnings
Signed-off-by: Sora Morimoto <sora@morimoto.io>
1 parent 7b7e4f2 commit 9543fab

File tree

2 files changed

+23
-16
lines changed

2 files changed

+23
-16
lines changed

src/templates-worker.js

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { resolve } from "node:path";
21
import * as path from "node:path";
32
import * as url from "node:url";
43
import * as Eta from "eta";
@@ -36,14 +35,21 @@ class TemplatesWorker {
3635
*/
3736
getTemplatePaths = (config) => {
3837
const __dirname = path.dirname(url.fileURLToPath(import.meta.url));
39-
const baseTemplatesPath = resolve(__dirname, "../templates/base");
40-
const defaultTemplatesPath = resolve(__dirname, "../templates/default");
41-
const modularTemplatesPath = resolve(__dirname, "../templates/modular");
38+
const baseTemplatesPath = path.resolve(__dirname, "../templates/base");
39+
const defaultTemplatesPath = path.resolve(
40+
__dirname,
41+
"../templates/default",
42+
);
43+
const modularTemplatesPath = path.resolve(
44+
__dirname,
45+
"../templates/modular",
46+
);
4247
const originalTemplatesPath = config.modular
4348
? modularTemplatesPath
4449
: defaultTemplatesPath;
4550
const customTemplatesPath =
46-
(config.templates && resolve(process.cwd(), config.templates)) || null;
51+
(config.templates && path.resolve(process.cwd(), config.templates)) ||
52+
null;
4753

4854
return {
4955
/** `templates/base` */
@@ -66,7 +72,7 @@ class TemplatesWorker {
6672
);
6773

6874
getTemplateFullPath = (path, fileName) => {
69-
const raw = resolve(path, "./", this.cropExtension(fileName));
75+
const raw = path.resolve(path, "./", this.cropExtension(fileName));
7076
const pathVariants = this.config.templateExtensions.map(
7177
(extension) => `${raw}${extension}`,
7278
);
@@ -171,13 +177,13 @@ class TemplatesWorker {
171177
return pathVariants.find((variant) => this.fileSystem.pathIsExist(variant));
172178
};
173179

174-
getTemplateContent = (path) => {
180+
getTemplateContent = (_path) => {
175181
const foundTemplatePathKey = lodash
176182
.keys(this.config.templatePaths)
177-
.find((key) => path.startsWith(`@${key}`));
183+
.find((key) => _path.startsWith(`@${key}`));
178184

179-
const rawPath = resolve(
180-
path.replace(
185+
const rawPath = path.resolve(
186+
_path.replace(
181187
`@${foundTemplatePathKey}`,
182188
this.config.templatePaths[foundTemplatePathKey],
183189
),
@@ -190,14 +196,16 @@ class TemplatesWorker {
190196

191197
const customPath =
192198
this.config.templatePaths.custom &&
193-
this.findTemplateWithExt(resolve(this.config.templatePaths.custom, path));
199+
this.findTemplateWithExt(
200+
path.resolve(this.config.templatePaths.custom, _path),
201+
);
194202

195203
if (customPath) {
196204
return this.fileSystem.getFileContent(customPath);
197205
}
198206

199207
const originalPath = this.findTemplateWithExt(
200-
resolve(this.config.templatePaths.original, path),
208+
path.resolve(this.config.templatePaths.original, _path),
201209
);
202210

203211
if (originalPath) {

src/util/file-system.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import * as fs from "node:fs";
2-
import { dirname, resolve } from "node:path";
32
import * as url from "node:url";
43
import * as lodash from "lodash";
54
import { Logger } from "./logger.js";
@@ -83,9 +82,9 @@ class FileSystem {
8382
return !!path && fs.existsSync(path);
8483
};
8584

86-
createFile = ({ path, fileName, content, withPrefix }) => {
87-
const __dirname = dirname(url.fileURLToPath(import.meta.url));
88-
const absolutePath = resolve(__dirname, path, `./${fileName}`);
85+
createFile = ({ path: _path, fileName, content, withPrefix }) => {
86+
const __dirname = path.dirname(url.fileURLToPath(import.meta.url));
87+
const absolutePath = path.resolve(__dirname, _path, `./${fileName}`);
8988
const fileContent = `${withPrefix ? FILE_PREFIX : ""}${content}`;
9089

9190
return fs.writeFileSync(absolutePath, fileContent, lodash.noop);

0 commit comments

Comments
 (0)