UNPKG

@backstage/cli

Version:

CLI for developing Backstage plugins and apps

35 lines (31 loc) 994 B
'use strict'; var errors = require('@backstage/errors'); var child_process = require('child_process'); var util = require('util'); const execFile = util.promisify(child_process.execFile); const versions = /* @__PURE__ */ new Map(); function detectYarnVersion(dir) { const cwd = dir != null ? dir : process.cwd(); if (versions.has(cwd)) { return versions.get(cwd); } const promise = Promise.resolve().then(async () => { try { const { stdout } = await execFile("yarn", ["--version"], { shell: true, cwd }); return stdout.trim().startsWith("1.") ? "classic" : "berry"; } catch (error) { errors.assertError(error); if ("stderr" in error) { process.stderr.write(error.stderr); } throw new errors.ForwardedError("Failed to determine yarn version", error); } }); versions.set(cwd, promise); return promise; } exports.detectYarnVersion = detectYarnVersion; //# sourceMappingURL=yarn-8315d2ff.cjs.js.map