Skip to content

Commit

Permalink
Rename package.json to package.json.orig when copying it to build fol…
Browse files Browse the repository at this point in the history
…der so it does not collide with schemas.
  • Loading branch information
afshin committed Sep 5, 2018
1 parent b3d5bb6 commit 728032a
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions buildutils/src/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,16 +126,13 @@ export namespace Build {
// Copy schemas.
schemas.forEach(schema => {
const file = path.basename(schema);
if (file === 'package.json') {
throw new Error('Cannot use name "package.json" for schema file');
}
fs.copySync(schema, path.join(destination, file));
});

// Write the package.json file for future comparison.
fs.copySync(
path.join(packageDir, 'package.json'),
path.join(destination, 'package.json')
path.join(destination, 'package.json.orig')
);
}

Expand All @@ -147,10 +144,9 @@ export namespace Build {
// Remove the existing directory if necessary.
if (fs.existsSync(destination)) {
try {
const oldPackageData = require(path.join(
destination,
'package.json'
));
const oldPackageData = utils.readJSONFile(
path.join(destination, 'package.json.orig')
);
if (oldPackageData.version === packageData.version) {
fs.removeSync(destination);
}
Expand All @@ -168,7 +164,7 @@ export namespace Build {
// Write the package.json file for future comparison.
fs.copySync(
path.join(packageDir, 'package.json'),
path.join(destination, 'package.json')
path.join(destination, 'package.json.orig')
);
}
});
Expand Down

0 comments on commit 728032a

Please sign in to comment.