Skip to content

Commit

Permalink
Merge pull request #5 from piotr-oles/fix/lock-file-create-dir
Browse files Browse the repository at this point in the history
fix: create dir if not exists for lock file
  • Loading branch information
piotr-oles authored Feb 24, 2021
2 parents 6c29756 + eb3a7c2 commit cafe479
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/sandbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,23 @@ async function createSandbox(logger: Logger = defaultLogger): Promise<Sandbox> {

const tryToStoreLockFile = async (managerFile: string) => {
if (lockFile && (await sandbox.exists(managerFile))) {
await fs.writeFile(lockFile, await sandbox.read(managerFile));
const lockFileDir = dirname(lockFile);
await retry(
async () => {
if (!(await fs.pathExists(lockFileDir))) {
await fs.mkdirp(lockFileDir);
}
},
logger,
options
);

await retry(
async () =>
fs.writeFile(lockFile!, await sandbox.read(managerFile)),
logger,
options
);
}
};

Expand Down

0 comments on commit cafe479

Please sign in to comment.