Skip to content

Commit

Permalink
Remove path-exists from dependencies and replace it with fs.existsSync (
Browse files Browse the repository at this point in the history
  • Loading branch information
halfzebra authored and alexdriaguine committed Jan 23, 2017
1 parent 728c68c commit 5dd218c
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 12 deletions.
1 change: 0 additions & 1 deletion packages/react-scripts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
"jest": "17.0.2",
"json-loader": "0.5.4",
"object-assign": "4.1.0",
"path-exists": "2.1.0",
"postcss-loader": "1.0.0",
"promise": "7.1.1",
"react-dev-utils": "^0.4.2",
Expand Down
3 changes: 1 addition & 2 deletions packages/react-scripts/scripts/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ require('dotenv').config({silent: true});
var chalk = require('chalk');
var fs = require('fs-extra');
var path = require('path');
var pathExists = require('path-exists');
var filesize = require('filesize');
var gzipSize = require('gzip-size').sync;
var webpack = require('webpack');
Expand All @@ -31,7 +30,7 @@ var checkRequiredFiles = require('react-dev-utils/checkRequiredFiles');
var recursive = require('recursive-readdir');
var stripAnsi = require('strip-ansi');

var useYarn = pathExists.sync(paths.yarnLockFile);
var useYarn = fs.existsSync(paths.yarnLockFile);

// Warn and crash if required files are missing
if (!checkRequiredFiles([paths.appHtml, paths.appIndexJs])) {
Expand Down
3 changes: 1 addition & 2 deletions packages/react-scripts/scripts/eject.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
var createJestConfig = require('../utils/createJestConfig');
var fs = require('fs-extra');
var path = require('path');
var pathExists = require('path-exists');
var paths = require('../config/paths');
var prompt = require('react-dev-utils/prompt');
var spawnSync = require('cross-spawn').sync;
Expand Down Expand Up @@ -144,7 +143,7 @@ prompt(
);
console.log();

if (pathExists.sync(paths.yarnLockFile)) {
if (fs.existsSync(paths.yarnLockFile)) {
console.log(cyan('Running yarn...'));
fs.removeSync(ownPath);
spawnSync('yarn', [], {stdio: 'inherit'});
Expand Down
5 changes: 2 additions & 3 deletions packages/react-scripts/scripts/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,13 @@
var fs = require('fs-extra');
var path = require('path');
var spawn = require('cross-spawn');
var pathExists = require('path-exists');
var chalk = require('chalk');

module.exports = function(appPath, appName, verbose, originalDirectory) {
var ownPackageName = require(path.join(__dirname, '..', 'package.json')).name;
var ownPath = path.join(appPath, 'node_modules', ownPackageName);
var appPackage = require(path.join(appPath, 'package.json'));
var useYarn = pathExists.sync(path.join(appPath, 'yarn.lock'));
var useYarn = fs.existsSync(path.join(appPath, 'yarn.lock'));

// Copy over some of the devDependencies
appPackage.dependencies = appPackage.dependencies || {};
Expand All @@ -36,7 +35,7 @@ module.exports = function(appPath, appName, verbose, originalDirectory) {
JSON.stringify(appPackage, null, 2)
);

var readmeExists = pathExists.sync(path.join(appPath, 'README.md'));
var readmeExists = fs.existsSync(path.join(appPath, 'README.md'));
if (readmeExists) {
fs.renameSync(path.join(appPath, 'README.md'), path.join(appPath, 'README.old.md'));
}
Expand Down
4 changes: 2 additions & 2 deletions packages/react-scripts/scripts/start.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ var formatWebpackMessages = require('react-dev-utils/formatWebpackMessages');
var getProcessForPort = require('react-dev-utils/getProcessForPort');
var openBrowser = require('react-dev-utils/openBrowser');
var prompt = require('react-dev-utils/prompt');
var pathExists = require('path-exists');
var fs = require('fs');
var config = require('../config/webpack.config.dev');
var paths = require('../config/paths');

var useYarn = pathExists.sync(paths.yarnLockFile);
var useYarn = fs.existsSync(paths.yarnLockFile);
var cli = useYarn ? 'yarn' : 'npm';
var isInteractive = process.stdout.isTTY;

Expand Down
4 changes: 2 additions & 2 deletions packages/react-scripts/utils/createJestConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@

// Note: this file does not exist after ejecting.

const pathExists = require('path-exists');
const fs = require('fs');
const paths = require('../config/paths');

module.exports = (resolve, rootDir, isEjecting) => {
// Use this instead of `paths.testsSetup` to avoid putting
// an absolute filename into configuration after ejecting.
const setupTestsFile = pathExists.sync(paths.testsSetup) ? '<rootDir>/src/setupTests.js' : undefined;
const setupTestsFile = fs.existsSync(paths.testsSetup) ? '<rootDir>/src/setupTests.js' : undefined;

// TODO: I don't know if it's safe or not to just use / as path separator
// in Jest configs. We need help from somebody with Windows to determine this.
Expand Down

0 comments on commit 5dd218c

Please sign in to comment.