Merge pull request #2979 from thelounge/xpaw/set-yarn-cache

Set yarn cache folder in the packages folder
This commit is contained in:
Pavel Djundik 2019-01-21 14:42:14 +02:00 committed by GitHub
commit f49bf19023
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 23 additions and 20 deletions

View file

@ -55,13 +55,8 @@ program
return Utils.executeYarnCommand(
"add",
"--json",
"--exact",
"--production",
"--ignore-scripts",
"--non-interactive",
"--cwd",
packagesPath,
"--exact",
`${json.name}@${json.version}`
).then(() => {
log.info(`${colors.green(json.name + " v" + json.version)} has been successfully installed.`);

View file

@ -39,11 +39,6 @@ program
return Utils.executeYarnCommand(
"remove",
"--json",
"--ignore-scripts",
"--non-interactive",
"--cwd",
packagesPath,
packageName
).then(() => {
log.info(`${colors.green(packageName)} has been successfully uninstalled.`);

View file

@ -20,13 +20,8 @@ program
const packagesList = JSON.parse(fs.readFileSync(packagesConfig)).dependencies;
const argsList = [
"upgrade",
"--latest",
"--json",
"--production",
"--ignore-scripts",
"--non-interactive",
"--cwd",
packagesPath,
"--latest",
];
let count = 0;
@ -44,7 +39,7 @@ program
log.info(`- ${colors.green(p)}`);
if (packagesList.hasOwnProperty(p)) {
argsList.splice(1, 0, p);
argsList.push(p);
count++;
} else {
log.error(`${colors.green(p)} is not installed.`);

View file

@ -107,7 +107,7 @@ class Utils {
return memo;
}
static executeYarnCommand(...parameters) {
static executeYarnCommand(command, ...parameters) {
// First off, try to find yarn inside of The Lounge
let yarn = path.join(
__dirname, "..", "..", "node_modules",
@ -127,9 +127,27 @@ class Utils {
}
}
const packagesPath = Helper.getPackagesPath();
const cachePath = path.join(packagesPath, "package_manager_cache");
const staticParameters = [
"--cache-folder",
cachePath,
"--cwd",
packagesPath,
"--json",
"--ignore-scripts",
"--non-interactive",
];
return new Promise((resolve, reject) => {
let success = false;
const add = require("child_process").spawn(process.execPath, [yarn, ...parameters]);
const add = require("child_process").spawn(process.execPath, [
yarn,
command,
...staticParameters,
...parameters,
]);
add.stdout.on("data", (data) => {
data.toString().trim().split("\n").forEach((line) => {