提交 350fbcfd 编写于 作者: fxy060608's avatar fxy060608

wip(uts): compiler

上级 4d311809
const fs = require('fs')
const path = require('path')
const {
normalizePath
} = require('../util')
function hasProjectYarn (cwd) {
return fs.existsSync(path.join(cwd, 'yarn.lock'))
}
function hasProjectPnpm (cwd) {
return fs.existsSync(path.join(cwd, 'pnpm-lock.yaml'))
}
function getInstallCommand (cwd) {
return hasProjectYarn(cwd)
? 'yarn add'
: hasProjectPnpm(cwd)
? 'pnpm i'
: 'npm i'
}
function installDepTips (
type,
module,
version
) {
const command =
`${getInstallCommand(process.cwd())} ${module + (version ? '@' + version : '')}${type === 'devDependencies' ? ' -D' : ''}`
return `Cannot find module: ${module}
Please run \`${command}\` and try again.`
}
module.exports = {
normalizePath
normalizePath,
installDepTips
}
......@@ -75,22 +75,20 @@ function resolveUtsFile(dir, extensions = ['.uts', '.ts', '.js']) {
}
function resolveUTSCompiler() {
let compilerPath = '';
if ((0, hbx_1.runByHBuilderX)()) {
if ((0, hbx_1.isInHBuilderX)()) {
try {
compilerPath = require.resolve(path_1.default.resolve(process.env.UNI_HBUILDERX_PLUGINS, 'uniapp-uts-v1'));
}
catch (e) { }
}
if (!compilerPath) {
try {
compilerPath = require.resolve('@dcloudio/uni-uts-v1', {
paths: [process.env.UNI_CLI_CONTEXT],
});
}
catch (e) { }
try {
compilerPath = require.resolve('@dcloudio/uni-uts-v1', {
paths: [process.env.UNI_CLI_CONTEXT],
});
}
if (!compilerPath) {
throw 'uts compiler is not found';
catch (e) {
console.error((0, utils_1.installDepTips)('devDependencies', '@dcloudio/uni-uts-v1', require('@dcloudio/uni-cli-shared/package.json').version));
process.exit(0);
}
return require(compilerPath);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册