UNPKG

cloudapp-cli

Version:

24 lines (17 loc) 644 B
const fs = require("fs"); const path = require("path"); const yaml = require("js-yaml"); exports.getLocalDir = (dir) => path.resolve(process.cwd(), dir); exports.getPackageId = (dir) => { const localDir = this.getLocalDir(dir); const packageConfigFile = path.resolve(localDir, "package.yaml"); if (!fs.existsSync(packageConfigFile)) { throw new Error(`当前目录下未找到应用 package.yaml 配置文件`); } // @ts-ignore const { id: pkgId } = yaml.load(fs.readFileSync(packageConfigFile, "utf8")); if (!pkgId) { throw new Error(`package.yaml 配置文件中未找到应用 id 配置`); } return pkgId; };