-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(babel-preset-gatsby): Convert path-serializer to TS (#22035)
* Convert path-serializer to TS * Fix tests * Update packages/babel-preset-gatsby/src/utils/path-serializer.ts Co-Authored-By: Michal Piechowiak <[email protected]> * ignore built files * Revert "ignore built files" This reverts commit 51236aa. * adjust ignore in build scripts * no overwrites needed * unformat Co-authored-by: Michal Piechowiak <[email protected]>
- Loading branch information
1 parent
f607506
commit f0d02dc
Showing
5 changed files
with
27 additions
and
21 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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { slash } from "gatsby-core-utils" | ||
|
||
const cleanNodeModules = (dir: string): string => { | ||
const x = dir.split(`node_modules/`) | ||
|
||
if (x.length <= 1) { | ||
return dir | ||
} | ||
|
||
return slash(`<PROJECT_ROOT>/node_modules/${x[1]}`) | ||
} | ||
|
||
export const test = (val: unknown): boolean => | ||
typeof val === `string` && val !== cleanNodeModules(val) | ||
|
||
export const print = ( | ||
val: string, | ||
serialize: (val: string) => string | ||
): string => serialize(cleanNodeModules(val)) |