1
0
mirror of synced 2026-04-03 06:28:35 +08:00

fix(runtime): 修复window系统下npm run playground 出错问题 #29

This commit is contained in:
roymondchen
2022-04-26 17:38:00 +08:00
committed by jia000
parent c8542367db
commit 6df8ce82a5
8 changed files with 16 additions and 5 deletions

View File

@@ -196,7 +196,8 @@ const generateEntryFile = function ({ entries, entryFile, type, componentFileAff
fs.writeFileSync(
path.resolve(entryPath(), entryFile),
prettyPrint(parse(jsString, { parser: require('recast/parsers/typescript') }), {
// window下需要将路径中\转换成/
prettyPrint(parse(jsString.replace(/\\/g, '/'), { parser: require('recast/parsers/typescript') }), {
tabWidth: 2,
trailingComma: true,
quote: 'single',
@@ -207,9 +208,10 @@ const generateEntryFile = function ({ entries, entryFile, type, componentFileAff
const installPackage = function (package) {
try {
execSync(`node -e "require.resolve('${package}')"`, { stdio: 'ignore' });
// window下需要将路径中\转换成/
execSync(`node -e "require.resolve('${package.replace(/\\/g, '/')}')"`, { stdio: 'ignore' });
} catch (e) {
execSync(`npm install ${package} --registry https://mirrors.tencent.com/npm/`, {
execSync(`npm install ${package}`, {
stdio: 'inherit',
cwd: pageRoot(),
});