File tree 4 files changed +14
-16
lines changed
internal-plugins/load-babel-config
4 files changed +14
-16
lines changed Original file line number Diff line number Diff line change 3
3
const fs = require ( `fs-extra` )
4
4
5
5
const apiRunnerNode = require ( `../../utils/api-runner-node` )
6
- const { withBasePath } = require ( ` ../../utils/path` )
6
+ import { withBasePath } from " ../../utils/path"
7
7
8
8
exports . onPreBootstrap = async ( { store, parentSpan } ) => {
9
9
const { directory, browserslist } = store . getState ( ) . program
Original file line number Diff line number Diff line change 1
- const { joinPath } = require ( ` gatsby-core-utils` )
2
- const { withBasePath, getCommonDir } = require ( ` ../path` )
3
- const os = require ( `os` )
1
+ import { joinPath } from " gatsby-core-utils"
2
+ import { withBasePath , getCommonDir } from " ../path"
3
+ import os from "os"
4
4
5
5
describe ( `paths` , ( ) => {
6
6
describe ( `joinPath` , ( ) => {
@@ -55,7 +55,7 @@ describe(`paths`, () => {
55
55
} )
56
56
57
57
describe ( `getCommonDir` , ( ) => {
58
- it . each ( [
58
+ it . each < [ string , { path1 : string ; path2 : string ; expected : string } ] > ( [
59
59
[
60
60
`posix: path2 is sub-path of path1` ,
61
61
{
Original file line number Diff line number Diff line change 1
- const path = require ( ` path` )
2
- const { joinPath } = require ( ` gatsby-core-utils` )
1
+ import path from " path"
2
+ import { joinPath } from " gatsby-core-utils"
3
3
4
- export function withBasePath ( basePath ) {
5
- return ( ...paths ) => joinPath ( basePath , ... paths )
6
- }
4
+ export const withBasePath = ( basePath : string ) => (
5
+ ...paths : string [ ]
6
+ ) : string => joinPath ( basePath , ... paths )
7
7
8
- export function withTrailingSlash ( basePath ) {
9
- return `${ basePath } /`
10
- }
8
+ export const withTrailingSlash = ( basePath : string ) : string => `${ basePath } /`
11
9
12
- const posixJoinWithLeadingSlash = paths =>
10
+ const posixJoinWithLeadingSlash = ( paths : string [ ] ) : string =>
13
11
path . posix . join (
14
12
...paths . map ( ( segment , index ) =>
15
13
segment === `` && index === 0 ? `/` : segment
16
14
)
17
15
)
18
16
19
- export function getCommonDir ( path1 , path2 ) {
17
+ export const getCommonDir = ( path1 : string , path2 : string ) : string => {
20
18
const path1Segments = path1 . split ( / [ / \\ ] / )
21
19
const path2Segments = path2 . split ( / [ / \\ ] / )
22
20
Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ const { actions } = require(`../redux/actions`)
9
9
const { getPublicPath } = require ( `./get-public-path` )
10
10
const debug = require ( `debug` ) ( `gatsby:webpack-config` )
11
11
const report = require ( `gatsby-cli/lib/reporter` )
12
- const { withBasePath, withTrailingSlash } = require ( ` ./path` )
12
+ import { withBasePath , withTrailingSlash } from " ./path"
13
13
const getGatsbyDependents = require ( `./gatsby-dependents` )
14
14
15
15
const apiRunnerNode = require ( `./api-runner-node` )
You can’t perform that action at this time.
0 commit comments