Skip to content

Commit 210f22b

Browse files
authored
Merge pull request #875 from acacode/fix-build-warnings-2
Fix build warnings
2 parents 7b7e4f2 + 062ac1e commit 210f22b

File tree

2 files changed

+25
-17
lines changed

2 files changed

+25
-17
lines changed

src/templates-worker.js

Lines changed: 21 additions & 13 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` */
@@ -65,8 +71,8 @@ class TemplatesWorker {
6571
path,
6672
);
6773

68-
getTemplateFullPath = (path, fileName) => {
69-
const raw = resolve(path, "./", this.cropExtension(fileName));
74+
getTemplateFullPath = (path_, 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: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as fs from "node:fs";
2-
import { dirname, resolve } from "node:path";
2+
import * as path from "node:path";
33
import * as url from "node:url";
44
import * as lodash from "lodash";
55
import { Logger } from "./logger.js";
@@ -83,9 +83,9 @@ class FileSystem {
8383
return !!path && fs.existsSync(path);
8484
};
8585

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

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

0 commit comments

Comments
 (0)