replace-own-deps.js 834 Bytes
Newer Older
1
2
3
4
#!/usr/bin/env node
/**
 * Copyright (c) 2015-present, Facebook, Inc.
 *
Sophie Alpert's avatar
Sophie Alpert committed
5
6
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
7
8
9
 */
'use strict';

10
// Replaces internal dependencies in package.json with local package paths.
11
12
13
14
15
16
17
18

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);

Clement Hoang's avatar
Clement Hoang committed
19
fs.readdirSync(packagesDir).forEach(name => {
20
21
22
  if (data.dependencies[name]) {
    data.dependencies[name] = 'file:' + path.join(packagesDir, name);
  }
Clement Hoang's avatar
Clement Hoang committed
23
});
24

Clement Hoang's avatar
Clement Hoang committed
25
26
27
28
fs.writeFile(pkgFilename, JSON.stringify(data, null, 2), 'utf8', err => {
  if (err) {
    throw err;
  }
29
  console.log('Replaced local dependencies.');
30
});