Skip to content

Commit

Permalink
[config] Fix getConfigFile dirname issue (#67)
Browse files Browse the repository at this point in the history
* ➖ Remove @babel/preset-env and babel-plugin-transform-import-meta

- babel-plugin-transform-import-meta was converting import.meta.url to require('url') which is not supported in esm syntax

* ♻️ Get __dirname in esm compatible way

- new URL is not supported in esm

* 📦 Update v0.2.5
  • Loading branch information
ninthsun91 committed Aug 20, 2023
1 parent b696d5b commit f30960c
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 22 deletions.
3 changes: 1 addition & 2 deletions babel.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
}
}
],
"module-extension-resolver",
"babel-plugin-transform-import-meta"
"module-extension-resolver"
]
}
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gitove",
"version": "0.2.4",
"version": "0.2.5",
"type": "module",
"description": "An interactive git cli tool for consistant commit messages.",
"license": "MIT",
Expand Down Expand Up @@ -53,7 +53,6 @@
"@typescript-eslint/parser": "^6.3.0",
"babel-plugin-module-extension-resolver": "^1.0.0",
"babel-plugin-module-resolver": "^5.0.0",
"babel-plugin-transform-import-meta": "^2.2.1",
"eslint": "^8.46.0",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-config-airbnb-typescript": "^17.1.0",
Expand Down
13 changes: 0 additions & 13 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions src/config/getConfigfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import path from 'path';
import { fileURLToPath } from 'url';
import { DEFAULT_CONFIG } from 'src/config/defaultConfig';

const dirname = fileURLToPath(new URL('.', import.meta.url));
const test = path.resolve(dirname, '../..');
const dirpath = path.join(test, 'gitoverc.json');
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const test = path.resolve(__dirname, '../..');
const dirpath = path.join(test, '.gitoverc.json');

const readUserConfigFile = () => {
const readfile: Configuration = JSON.parse(readFileSync(dirpath, { encoding: 'utf-8', flag: 'r' }));
Expand Down
4 changes: 2 additions & 2 deletions src/config/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export * from './defaultConfig';
// export * from './getConfigfile';
// export * from './getValueFromConfig';
export * from './getConfigfile';
export * from './getValueFromConfig';

0 comments on commit f30960c

Please sign in to comment.