实际上我创建了一个 npm 包,如果我在其中运行它会为我创建一些文件,而它会在 node_modules 中创建它,所以我添加../
了这个地方,但它仍然在包文件夹之外的 node_modules 中创建......
这是我的包裹代码
import { default as Mustache } from 'mustache';
import { readFileSync, writeFileSync } from 'fs';
import { resolve } from 'path';
import path from 'path';
import { fileURLToPath } from 'url';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
export function css() {
const templatePath = resolve(__dirname, './template.mustache');
const outputPath = resolve(__dirname, '../animate.css');
const templateContent = readFileSync(templatePath, 'utf8');
const data = {
justifyContent: 'center'
};
const fileContent = Mustache.render(templateContent, data);
writeFileSync(outputPath, fileContent, 'utf8');
};
export function js() {
const templatePath = resolve(__dirname, './templates.mustache');
const outputPath = resolve(__dirname, '../animate.js');
const templateContent = readFileSync(templatePath, 'utf8');
const data = {
justifyContent: 'center'
};
const fileContent = Mustache.render(templateContent, data);
writeFileSync(outputPath, fileContent, 'utf8');
};
export function html() {
const templatePath = resolve(__dirname, './templatess.mustache');
const outputPath = resolve(__dirname, '../index.html');
const templateContent = readFileSync(templatePath, 'utf8');
const data = {
justifyContent: 'center'
};
const fileContent = Mustache.render(templateContent, data);
writeFileSync(outputPath, fileContent, 'utf8');
};
export function all() {
html();
css();
js();
}
任何人都可以请帮助...
先感谢您... !!!