Skip to content

Commit

Permalink
Clean up temporary package.json files.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ben Newman committed Nov 2, 2016
1 parent 643a9f1 commit 31e7b8b
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions tools/cli/default-npm-deps.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,28 @@ import {
pathJoin,
statOrNull,
writeFile,
unlink,
} from "../fs/files.js";

const INSTALL_JOB_MESSAGE = "installing dependencies from package.json";

export function install(appDir) {
const testAppPkgJsonPath = pathJoin(appDir, "package.json");
const packageJsonPath = pathJoin(appDir, "package.json");
const needTempPackageJson = ! statOrNull(packageJsonPath);

if (! statOrNull(testAppPkgJsonPath)) {
if (needTempPackageJson) {
const { dependencies } = require("../static-assets/skel/package.json");

// Write a minimial package.json with the same dependencies as the
// default new-app package.json file.
writeFile(
testAppPkgJsonPath,
packageJsonPath,
JSON.stringify({ dependencies }, null, 2) + "\n",
"utf8",
);
}

return buildmessage.enterJob(INSTALL_JOB_MESSAGE, function () {
const ok = buildmessage.enterJob(INSTALL_JOB_MESSAGE, function () {
const { runNpmCommand } = require("../isobuild/meteor-npm.js");

const installResult = runNpmCommand(["install"], appDir);
Expand All @@ -36,4 +38,11 @@ export function install(appDir) {

return true;
});

if (needTempPackageJson) {
// Clean up the temporary package.json file created above.
unlink(packageJsonPath);
}

return ok;
}

0 comments on commit 31e7b8b

Please sign in to comment.