Skip to content

Commit 59871cb

Browse files
committed
refactor: added check to verify whether cwd path exists or not
1 parent 9960eb9 commit 59871cb

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

  • packages/contentstack-utilities/src/logger

packages/contentstack-utilities/src/logger/log.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,10 @@ function getLogPath(): string {
8686
// 3. Use current working directory (where user ran the command)
8787
try {
8888
const cwdPath = path.join(process.cwd(), 'logs');
89-
const testDir = path.dirname(cwdPath);
90-
fs.accessSync(testDir, fs.constants.W_OK);
89+
if (!fs.existsSync(cwdPath)) {
90+
fs.mkdirSync(cwdPath, { recursive: true });
91+
}
92+
fs.accessSync(cwdPath, fs.constants.W_OK);
9193
return cwdPath;
9294
} catch (error) {
9395
// If current directory is not writable, fall back to home directory

0 commit comments

Comments
 (0)