Skip to content

Commit

Permalink
fix(contract): create file descriptor at not existing path
Browse files Browse the repository at this point in the history
  • Loading branch information
davidyuk committed Jul 19, 2022
1 parent 37b490f commit 485117e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/actions/contract.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ export async function deploy(walletPath, args, options) {
// eslint-disable-next-line no-underscore-dangle
aci: contract._aci,
};
fs.writeFileSync(options.descrPath, JSON.stringify(descriptor, undefined, 2));
await fs.promises.mkdir(path.parse(options.descrPath).dir, { recursive: true });
await fs.promises.writeFile(options.descrPath, JSON.stringify(descriptor, undefined, 2));
if (options.json) print({ ...result, descrPath: options.descrPath });
else {
print('Contract was successfully deployed');
Expand Down
2 changes: 1 addition & 1 deletion test/contract.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ describe('CLI Contract Module', function contractTests() {
});

it('deploys contract with custom descrPath', async () => {
const descrPath = './testDescriptor.json';
const descrPath = './not-existing/testDescriptor.json';
await executeContract([
'deploy',
WALLET_NAME, '--password', 'test',
Expand Down

0 comments on commit 485117e

Please sign in to comment.