Provide fake $HOME env to Yarn commands

This commit is contained in:
Pavel Djundik 2019-12-13 17:45:10 +02:00
parent 51360711c9
commit 24e41327a3
3 changed files with 20 additions and 13 deletions

View file

@ -66,12 +66,7 @@ program
);
}
return Utils.executeYarnCommand(
"add",
"--production",
"--exact",
`${json.name}@${json.version}`
)
return Utils.executeYarnCommand("add", "--exact", `${json.name}@${json.version}`)
.then(() => {
log.info(
`${colors.green(

View file

@ -18,7 +18,7 @@ program
const packagesPath = Helper.getPackagesPath();
const packagesConfig = path.join(packagesPath, "package.json");
const packagesList = JSON.parse(fs.readFileSync(packagesConfig)).dependencies;
const argsList = ["upgrade", "--production", "--latest"];
const argsList = ["upgrade", "--latest"];
let count = 0;

View file

@ -106,14 +106,26 @@ class Utils {
"--non-interactive",
];
const env = {
// We only ever operate in production mode
NODE_ENV: "production",
// If The Lounge runs from a user that does not have a home directory,
// yarn may fail when it tries to read certain folders,
// we give it an existing folder so the reads do not throw a permission error.
// Yarn uses os.homedir() to figure out the path, which internally reads
// from the $HOME env on unix. On Windows it uses $USERPROFILE, but
// the user folder should always exist on Windows, so we don't set it.
HOME: cachePath,
};
return new Promise((resolve, reject) => {
let success = false;
const add = require("child_process").spawn(process.execPath, [
yarn,
command,
...staticParameters,
...parameters,
]);
const add = require("child_process").spawn(
process.execPath,
[yarn, command, ...staticParameters, ...parameters],
{env: env}
);
add.stdout.on("data", (data) => {
data.toString()