Skip to content

Commit

Permalink
fix(js-toolkit-core): fix "No such file or directory .liferay.json" e…
Browse files Browse the repository at this point in the history
…rror

Fixes liferay#992
  • Loading branch information
izaera committed Sep 1, 2022
1 parent 3403992 commit 260bb08
Showing 1 changed file with 15 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,27 @@ export default class Deploy {
storeDir(deployDir: FilePath): void {
(this as object)['dir'] = deployDir.resolve();

this._store('dir');
this._store('dir', 'path');
}

_store(property: string): void {
_store(property: string, configProperty?: string): void {
configProperty = configProperty ?? property;

const file = this._project.dir.join('.liferay.json');

const liferayJson = JSON.parse(
fs.readFileSync(file.asNative, 'utf8')
) as LiferayJson;
let liferayJson: LiferayJson = {};

try {
liferayJson = JSON.parse(fs.readFileSync(file.asNative, 'utf8'));
}
catch (error) {
if (error.code !== 'ENOENT') {
throw error;
}
}

liferayJson.deploy = liferayJson.deploy || {};
liferayJson.deploy[property] = this[property].toString();
liferayJson.deploy[configProperty] = this[property].toString();

fs.writeFileSync(
file.asNative,
Expand Down

0 comments on commit 260bb08

Please sign in to comment.