10
10
// @remove -on-eject-end
11
11
'use strict' ;
12
12
13
- var path = require ( 'path' ) ;
14
- var fs = require ( 'fs' ) ;
15
- var url = require ( 'url' ) ;
13
+ const path = require ( 'path' ) ;
14
+ const fs = require ( 'fs' ) ;
15
+ const url = require ( 'url' ) ;
16
16
17
17
// Make sure any symlinks in the project folder are resolved:
18
18
// https://github.com/facebookincubator/create-react-app/issues/637
19
- var appDirectory = fs . realpathSync ( process . cwd ( ) ) ;
19
+ const appDirectory = fs . realpathSync ( process . cwd ( ) ) ;
20
20
function resolveApp ( relativePath ) {
21
21
return path . resolve ( appDirectory , relativePath ) ;
22
22
}
@@ -36,20 +36,20 @@ function resolveApp(relativePath) {
36
36
// Otherwise, we risk importing Node.js core modules into an app instead of Webpack shims.
37
37
// https://github.com/facebookincubator/create-react-app/issues/1023#issuecomment-265344421
38
38
39
- var nodePaths = ( process . env . NODE_PATH || '' )
39
+ const nodePaths = ( process . env . NODE_PATH || '' )
40
40
. split ( process . platform === 'win32' ? ';' : ':' )
41
41
. filter ( Boolean )
42
42
. filter ( folder => ! path . isAbsolute ( folder ) )
43
43
. map ( resolveApp ) ;
44
44
45
- var envPublicUrl = process . env . PUBLIC_URL ;
45
+ const envPublicUrl = process . env . PUBLIC_URL ;
46
46
47
47
function ensureSlash ( path , needsSlash ) {
48
- var hasSlash = path . endsWith ( '/' ) ;
48
+ const hasSlash = path . endsWith ( '/' ) ;
49
49
if ( hasSlash && ! needsSlash ) {
50
50
return path . substr ( path , path . length - 1 ) ;
51
51
} else if ( ! hasSlash && needsSlash ) {
52
- return path + '/' ;
52
+ return ` ${ path } /` ;
53
53
} else {
54
54
return path ;
55
55
}
@@ -66,8 +66,8 @@ function getPublicUrl(appPackageJson) {
66
66
// We can't use a relative path in HTML because we don't want to load something
67
67
// like /todos/42/static/js/bundle.7289d.js. We have to know the root.
68
68
function getServedPath ( appPackageJson ) {
69
- var publicUrl = getPublicUrl ( appPackageJson ) ;
70
- var servedUrl = envPublicUrl || (
69
+ const publicUrl = getPublicUrl ( appPackageJson ) ;
70
+ const servedUrl = envPublicUrl || (
71
71
publicUrl ? url . parse ( publicUrl ) . pathname : '/'
72
72
) ;
73
73
return ensureSlash ( servedUrl , true ) ;
@@ -114,9 +114,9 @@ module.exports = {
114
114
ownNodeModules : resolveOwn ( 'node_modules' ) , // This is empty on npm 3
115
115
} ;
116
116
117
- var ownPackageJson = require ( '../package.json' ) ;
118
- var reactScriptsPath = resolveApp ( `node_modules/${ ownPackageJson . name } ` ) ;
119
- var reactScriptsLinked = fs . existsSync ( reactScriptsPath ) && fs . lstatSync ( reactScriptsPath ) . isSymbolicLink ( ) ;
117
+ const ownPackageJson = require ( '../package.json' ) ;
118
+ const reactScriptsPath = resolveApp ( `node_modules/${ ownPackageJson . name } ` ) ;
119
+ const reactScriptsLinked = fs . existsSync ( reactScriptsPath ) && fs . lstatSync ( reactScriptsPath ) . isSymbolicLink ( ) ;
120
120
121
121
// config before publish: we're in ./packages/react-scripts/config/
122
122
if ( ! reactScriptsLinked && __dirname . indexOf ( path . join ( 'packages' , 'react-scripts' , 'config' ) ) !== - 1 ) {
0 commit comments