diff --git a/dist/index.js b/dist/index.js index ee2045b..94464ee 100644 --- a/dist/index.js +++ b/dist/index.js @@ -21,29 +21,29 @@ const commandLineArgs = yargs_1.default .demandOption(['source'], 'The source (s) parameter is required.') .help('help') .argv; -const jsonSchemaSourceDirectory = path_1.default.resolve(__dirname, commandLineArgs.source); +const jsonSchemaSourceDirectory = path_1.default.resolve(process.cwd(), commandLineArgs.source); let interfaceTarget; if (commandLineArgs.i) { - interfaceTarget = path_1.default.resolve(__dirname, commandLineArgs.source); + interfaceTarget = path_1.default.resolve(process.cwd(), commandLineArgs.source); } else { interfaceTarget = path_1.default.join(jsonSchemaSourceDirectory, '..', 'json-schema-interfaces'); } let validatorTarget; if (commandLineArgs.v) { - validatorTarget = path_1.default.resolve(__dirname, commandLineArgs.source); + validatorTarget = path_1.default.resolve(process.cwd(), commandLineArgs.source); } else { validatorTarget = path_1.default.join(jsonSchemaSourceDirectory, '..', 'json-schema-validators'); } let patterns = {}; if (commandLineArgs.patterns) { - patterns = require(path_1.default.resolve(__dirname, commandLineArgs.patterns)); + patterns = require(path_1.default.resolve(process.cwd(), commandLineArgs.patterns)); } const SOURCE_JSON_SCHEMA_DIR = jsonSchemaSourceDirectory; const TARGET_TYPESCRIPT_INTERFACE_DIR = interfaceTarget; const TARGET_VALIDATORS_DIR = validatorTarget; -const TEMPORARY_DIR = path_1.default.resolve(__dirname, './json-schema-transformation-tmp'); +const TEMPORARY_DIR = path_1.default.resolve(process.cwd(), './json-schema-transformation-tmp'); const TEMPORARY_SCHEMA_DIR = path_1.default.join(TEMPORARY_DIR, 'schema'); console.log("JSON SCHEMA LOCATION:", SOURCE_JSON_SCHEMA_DIR); console.log("TYPESCRIPT INTERFACES LOCATION:", TARGET_TYPESCRIPT_INTERFACE_DIR); diff --git a/dist/index.js.map b/dist/index.js.map index 29b4782..b99bb40 100644 --- a/dist/index.js.map +++ b/dist/index.js.map @@ -1 +1 @@ -{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"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,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;IACf,OAAO,CAAC,KAAK,CAAC,4BAA4B,EAAE,GAAG,CAAC,CAAC;AACnD,CAAC,CAAC,CAAC"} \ No newline at end of file diff --git a/src/index.ts b/src/index.ts index b82653c..6c49278 100644 --- a/src/index.ts +++ b/src/index.ts @@ -18,32 +18,32 @@ const commandLineArgs = yargs .help('help') .argv -const jsonSchemaSourceDirectory = path.resolve(__dirname, commandLineArgs.source); +const jsonSchemaSourceDirectory = path.resolve(process.cwd(), commandLineArgs.source); let interfaceTarget; if (commandLineArgs.i) { - interfaceTarget = path.resolve(__dirname, commandLineArgs.source); + interfaceTarget = path.resolve(process.cwd(), commandLineArgs.source); } else { interfaceTarget = path.join(jsonSchemaSourceDirectory, '..', 'json-schema-interfaces'); } let validatorTarget; if (commandLineArgs.v) { - validatorTarget = path.resolve(__dirname, commandLineArgs.source); + validatorTarget = path.resolve(process.cwd(), commandLineArgs.source); } else { validatorTarget = path.join(jsonSchemaSourceDirectory, '..', 'json-schema-validators'); } let patterns = {}; if (commandLineArgs.patterns) { - patterns = require(path.resolve(__dirname, commandLineArgs.patterns)); + patterns = require(path.resolve(process.cwd(), commandLineArgs.patterns)); } const SOURCE_JSON_SCHEMA_DIR = jsonSchemaSourceDirectory; const TARGET_TYPESCRIPT_INTERFACE_DIR = interfaceTarget; const TARGET_VALIDATORS_DIR = validatorTarget; -const TEMPORARY_DIR = path.resolve(__dirname, './json-schema-transformation-tmp'); +const TEMPORARY_DIR = path.resolve(process.cwd(), './json-schema-transformation-tmp'); const TEMPORARY_SCHEMA_DIR = path.join(TEMPORARY_DIR, 'schema'); console.log("JSON SCHEMA LOCATION:", SOURCE_JSON_SCHEMA_DIR);