forked from facebook/create-react-app
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreplace-own-deps.js
executable file
·30 lines (25 loc) · 953 Bytes
/
replace-own-deps.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
#!/usr/bin/env node
/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
'use strict';
// Replaces internal dependencies in package.json with local package paths.
const fs = require('fs');
const path = require('path');
const packagesDir = path.join(__dirname, '../packages');
const pkgFilename = path.join(packagesDir, 'react-scripts/package.json');
const data = require(pkgFilename);
fs.readdirSync(packagesDir).forEach((name) => {
if (data.dependencies[name]) {
data.dependencies[name] = 'file:' + path.join(packagesDir, name);
}
})
fs.writeFile(pkgFilename, JSON.stringify(data, null, 2), 'utf8', (err) => {
if (err) throw err;
console.log('Replaced local dependencies.');
});