-
Notifications
You must be signed in to change notification settings - Fork 425
/
paths.js
37 lines (30 loc) · 1.22 KB
/
paths.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
var path = require('path');
var fs = require('fs');
//try to detect if user is using a custom scripts version
var custom_scripts = process.env.REACT_SCRIPTS_VERSION || false;
const cs_index = process.argv.indexOf('--scripts-version');
if (cs_index > -1 && cs_index + 1 <= process.argv.length) {
custom_scripts = process.argv[cs_index + 1];
}
//Allow custom overrides package location
const projectDir = path.resolve(fs.realpathSync(process.cwd()));
const customPath = require(path.resolve(projectDir, 'package.json'))['config-overrides-path'];
var config_overrides = customPath
? `${ projectDir }/${ customPath }`
: `${ projectDir }/config-overrides`;
const co_index = process.argv.indexOf('--config-overrides');
if (co_index > -1 && co_index + 1 <= process.argv.length) {
config_overrides = path.resolve(process.argv[co_index + 1]);
process.argv.splice(co_index, 2);
}
const scriptVersion = custom_scripts || 'react-scripts';
const modulePath = path.join(
require.resolve(`${scriptVersion}/package.json`),
'..'
);
const paths = require(modulePath + '/config/paths');
module.exports = Object.assign({
scriptVersion: modulePath,
configOverrides: config_overrides,
customScriptsIndex: (custom_scripts ? cs_index : -1)
}, paths);