From e6d03bb8f35aca5ea40946346c056ee94fc1c487 Mon Sep 17 00:00:00 2001 From: danding Date: Fri, 20 Sep 2024 23:13:47 +0800 Subject: [PATCH] # Fix TypeError in process.chdir() call When running the Messari Subgraph CLI, users may encounter the following error: ``` TypeError: The "directory" argument must be of type string. Received undefined at wrappedChdir (node:internal/bootstrap/switches/does_own_process_state:129:3) at process.chdir (node:internal/worker:110:5) at Object. (C:\Users\Administrator\AppData\Roaming\fnm\node-versions\v20.16.0\installation\node_modules\messari-subgraph-cli\bin\env.ts:4:9) ... ``` --- bin/env.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/bin/env.ts b/bin/env.ts index d921cef..8dd70f5 100644 --- a/bin/env.ts +++ b/bin/env.ts @@ -1,7 +1,13 @@ const execSync = require('child_process').execSync // Change to the directory of this file -process.chdir(process.env.PWD) +if (process.cwd()) { + process.chdir(process.cwd()); +} else { + console.error('Current working directory is undefined'); + process.exit(1); +} + // Get the path to the head of the `Subgraphs` repo export const MESSARI_REPO_PATH = execSync('git rev-parse --show-toplevel')