Skip to content

Commit

Permalink
Merge pull request #2 from danb4r/devel
Browse files Browse the repository at this point in the history
Changed verbose flag to capital -V to not get confused with -v from a…
  • Loading branch information
danb4r authored Mar 27, 2023
2 parents 2515526 + 1af2072 commit 1519fd9
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Add it to your `package.json` module build script after your tsc run.

## How it works

**fix-tsc-es-imports** looks for every `.js` file at the `compileOptions.outDir` folder found on the default `tsconfig.json` or another provided `.json` config file, and fixes all extensionless typescript **relative only** imports and exports, adding `.js` extensions to them.
**fix-tsc-es-imports** looks for every `.js` file at the `compileOptions.outDir` folder found on the default `tsconfig.json` or another provided `.json` config file. Then it fixes all extensionless typescript **relative** imports and exports, adding `.js` extensions to them.

## Usage

Expand All @@ -29,7 +29,7 @@ fix_tsc_imports [-h|--help] [-y] [alternative_tsconfig.json]
-h --help usage info
-y --yes ignore confirmation and proceed straight away
-v --verbose verbose, outputs sed changed strings
-V --verbose verbose, outputs sed changed strings
-d --dry dry run, do not change anything and output sed changed strings (implied -v and -y)
```

Expand Down
11 changes: 6 additions & 5 deletions fix_tsc_es_imports.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ function getArgs() {

if (element === "-h" || element === "--help") printHelp();
else if (element === "-y" || element === "--yes") setup.ask_to_proceed = false;
else if (element === "-v" || element === "--verbose") setup.verbose = true;
else if (element === "-V" || element === "--verbose") setup.verbose = true;
else if (element === "-d" || element === "--dry") {
setup.dry_run = true;
setup.verbose = true;
Expand All @@ -69,14 +69,15 @@ function getArgs() {
* Prints a basic usage help
*/
function printHelp() {
console.log(`
fix-tsc-es-imports looks for every '.js' file at the 'compileOptions.outDir' folder found on the default 'tsconfig.json' or another provided '.json' config file, and fixes all extensionless typescript relative only imports and exports, adding '.js' extensions to them.
console.log(`fix-tsc-es-imports:
Looks for every '.js' file at the 'compileOptions.outDir' folder found on the default 'tsconfig.json' or another provided '.json' config file. Then fixes all extensionless typescript relative imports and exports, adding '.js' extensions to them.
Usage: fix_tsc_imports [-h|--help] [-y] [alternative_tsconfig.json]
-h --help usage info
-y --yes ignore confirmation and proceed straight away
-v --verbose verbose, outputs sed changed strings
-V --verbose verbose, outputs sed changed strings
-d --dry dry run, do not change anything and output sed changed strings (implied -v and -y)
An alternative 'tsconfig.json' can be provided. It must have a '.json' extension. For example:
Expand Down Expand Up @@ -106,7 +107,7 @@ function proceed(foundFiles) {
if (!setup.dry_run) {
sh.sed("-i", MATCH_PATTERN, "$1$2$3.js$4", foundFiles);
console.log(APP_ID, "done.");
} else console.log(APP_ID, "nothing done. Dry run.");
} else console.log(APP_ID, "nothing done, dry run.");
}

/**
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "fix-tsc-es-imports",
"version": "0.1.1",
"version": "0.1.2",
"description": "fix-tsc-es-imports uses shelljs sed to fix default extensionless typescript ECMAScript compiled code relative imports and exports, properly adding .js extensions.",
"type": "module",
"main": "fix_tsc_es_imports.js",
Expand Down

0 comments on commit 1519fd9

Please sign in to comment.