This repository has been archived by the owner on Aug 16, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(tools): add
tsc-prog
to build workflow
- Loading branch information
1 parent
7c38efc
commit a14fd44
Showing
9 changed files
with
223 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import logger from '@flex-development/grease/utils/logger.util' | ||
import LogLevel from '@flex-development/log/enums/log-level.enum' | ||
import type { ReplaceResult } from 'replace-in-file' | ||
import replace from 'replace-in-file' | ||
|
||
/** | ||
* @file Helpers - fixImportPaths | ||
* @module tools/helpers/fixImportPaths | ||
*/ | ||
|
||
/** | ||
* When using [TypeScript path mapping][1], path aliases are interpreted exactly | ||
* as written. This function fixes all import paths that match either of the | ||
* following regex patterns: | ||
* | ||
* - `/(../.*)?node_modules/g` | ||
* - `/@packages/g` | ||
* | ||
* @see https://github.com/adamreisnz/replace-in-file | ||
* | ||
* [1]: https://www.typescriptlang.org/docs/handbook/module-resolution.html#path-mapping | ||
* | ||
* @param {string} [message] - Success log message | ||
* @param {any[]} [args=[]] - Success log arguments | ||
* @return {ReplaceResult[]} Replacement results | ||
*/ | ||
const fixImportPaths = ( | ||
message?: string, | ||
args: any[] = [] | ||
): ReplaceResult[] => { | ||
let results: ReplaceResult[] = [] | ||
|
||
try { | ||
results = replace.sync({ | ||
files: ['./cjs/**/*', './esm/**/*', './types/**/*'], | ||
from: new RegExp(`(../.*)?${process.env.NODE_MODULES}/`), | ||
to: '' | ||
}) | ||
} catch (error) { | ||
logger({}, (error as Error).message, [], LogLevel.ERROR) | ||
} | ||
|
||
if (message) logger({}, message, args) | ||
return results | ||
} | ||
|
||
export default fixImportPaths |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.