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

View file

@ -39,11 +39,6 @@ program
return Utils.executeYarnCommand( return Utils.executeYarnCommand(
"remove", "remove",
"--json",
"--ignore-scripts",
"--non-interactive",
"--cwd",
packagesPath,
packageName packageName
).then(() => { ).then(() => {
log.info(`${colors.green(packageName)} has been successfully uninstalled.`); 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 packagesList = JSON.parse(fs.readFileSync(packagesConfig)).dependencies;
const argsList = [ const argsList = [
"upgrade", "upgrade",
"--latest",
"--json",
"--production", "--production",
"--ignore-scripts", "--latest",
"--non-interactive",
"--cwd",
packagesPath,
]; ];
let count = 0; let count = 0;
@ -44,7 +39,7 @@ program
log.info(`- ${colors.green(p)}`); log.info(`- ${colors.green(p)}`);
if (packagesList.hasOwnProperty(p)) { if (packagesList.hasOwnProperty(p)) {
argsList.splice(1, 0, p); argsList.push(p);
count++; count++;
} else { } else {
log.error(`${colors.green(p)} is not installed.`); log.error(`${colors.green(p)} is not installed.`);

View file

@ -107,7 +107,7 @@ class Utils {
return memo; return memo;
} }
static executeYarnCommand(...parameters) { static executeYarnCommand(command, ...parameters) {
// First off, try to find yarn inside of The Lounge // First off, try to find yarn inside of The Lounge
let yarn = path.join( let yarn = path.join(
__dirname, "..", "..", "node_modules", __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) => { return new Promise((resolve, reject) => {
let success = false; 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) => { add.stdout.on("data", (data) => {
data.toString().trim().split("\n").forEach((line) => { data.toString().trim().split("\n").forEach((line) => {