Skip to content

Commit 69e41d3

Browse files
committed
Replace path-exists with fs.existsSync
It's not deprecated anymore, see nodejs/node#8364
1 parent 76de1cc commit 69e41d3

File tree

11 files changed

+14
-24
lines changed

11 files changed

+14
-24
lines changed

packages/babel-cli/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
"glob": "^5.0.5",
1818
"lodash": "^4.2.0",
1919
"output-file-sync": "^1.1.0",
20-
"path-exists": "^1.0.0",
2120
"path-is-absolute": "^1.0.0",
2221
"slash": "^1.0.0",
2322
"source-map": "^0.5.0",

packages/babel-cli/src/babel/dir.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
let outputFileSync = require("output-file-sync");
2-
let pathExists = require("path-exists");
32
let slash = require("slash");
43
let path = require("path");
54
let util = require("./util");
@@ -45,7 +44,7 @@ module.exports = function (commander, filenames) {
4544
}
4645

4746
function handle(filename) {
48-
if (!pathExists.sync(filename)) return;
47+
if (!fs.existsSync(filename)) return;
4948

5049
let stat = fs.statSync(filename);
5150

packages/babel-cli/src/babel/file.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
let convertSourceMap = require("convert-source-map");
2-
let pathExists = require("path-exists");
32
let sourceMap = require("source-map");
43
let slash = require("slash");
54
let path = require("path");
@@ -109,7 +108,7 @@ module.exports = function (commander, filenames, opts) {
109108
results = [];
110109

111110
_.each(filenames, function (filename) {
112-
if (!pathExists.sync(filename)) return;
111+
if (!fs.existsSync(filename)) return;
113112

114113
let stat = fs.statSync(filename);
115114
if (stat.isDirectory()) {

packages/babel-cli/src/babel/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
require("babel-core");
55

6-
let pathExists = require("path-exists");
6+
let fs = require("fs");
77
let commander = require("commander");
88
let kebabCase = require("lodash/kebabCase");
99
let options = require("babel-core").options;
@@ -70,7 +70,7 @@ let filenames = commander.args.reduce(function (globbed, input) {
7070
filenames = uniq(filenames);
7171

7272
each(filenames, function (filename) {
73-
if (!pathExists.sync(filename)) {
73+
if (!fs.existsSync(filename)) {
7474
errors.push(filename + " doesn't exist");
7575
}
7676
});

packages/babel-cli/test/index.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ var child = require("child_process");
77
var path = require("path");
88
var chai = require("chai");
99
var fs = require("fs");
10-
var pathExists = require("path-exists");
1110
var _ = require("lodash");
1211

1312
var fixtureLoc = path.join(__dirname, "fixtures");
@@ -25,7 +24,7 @@ var pluginLocs = [
2524

2625
var readDir = function (loc) {
2726
var files = {};
28-
if (pathExists.sync(loc)) {
27+
if (fs.existsSync(loc)) {
2928
_.each(readdir(loc), function (filename) {
3029
files[filename] = helper.readFile(path.join(loc, filename));
3130
});
@@ -130,7 +129,7 @@ var buildTest = function (binName, testName, opts) {
130129

131130
var clear = function () {
132131
process.chdir(__dirname);
133-
if (pathExists.sync(tmpLoc)) rimraf.sync(tmpLoc);
132+
if (fs.existsSync(tmpLoc)) rimraf.sync(tmpLoc);
134133
fs.mkdirSync(tmpLoc);
135134
process.chdir(tmpLoc);
136135
};
@@ -150,11 +149,11 @@ _.each(fs.readdirSync(fixtureLoc), function (binName) {
150149
};
151150

152151
var optionsLoc = path.join(testLoc, "options.json");
153-
if (pathExists.sync(optionsLoc)) _.merge(opts, require(optionsLoc));
152+
if (fs.existsSync(optionsLoc)) _.merge(opts, require(optionsLoc));
154153

155154
_.each(["stdout", "stdin", "stderr"], function (key) {
156155
var loc = path.join(testLoc, key + ".txt");
157-
if (pathExists.sync(loc)) {
156+
if (fs.existsSync(loc)) {
158157
opts[key] = helper.readFile(loc);
159158
} else {
160159
opts[key] = opts[key] || "";
@@ -165,7 +164,7 @@ _.each(fs.readdirSync(fixtureLoc), function (binName) {
165164
opts.inFiles = readDir(path.join(testLoc, "in-files"));
166165

167166
var babelrcLoc = path.join(testLoc, ".babelrc");
168-
if (pathExists.sync(babelrcLoc)) {
167+
if (fs.existsSync(babelrcLoc)) {
169168
// copy .babelrc file to tmp directory
170169
opts.inFiles['.babelrc'] = helper.readFile(babelrcLoc);
171170
}

packages/babel-core/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
"json5": "^0.5.0",
4040
"lodash": "^4.2.0",
4141
"minimatch": "^3.0.2",
42-
"path-exists": "^1.0.0",
4342
"path-is-absolute": "^1.0.0",
4443
"private": "^0.1.6",
4544
"slash": "^1.0.0",

packages/babel-core/src/transformation/file/options/build-config-chain.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import type Logger from "../logger";
33
import resolve from "../../../helpers/resolve";
44
import json5 from "json5";
55
import isAbsolute from "path-is-absolute";
6-
import pathExists from "path-exists";
76
import path from "path";
87
import fs from "fs";
98

@@ -17,7 +16,7 @@ const PACKAGE_FILENAME = "package.json";
1716
function exists(filename) {
1817
let cached = existsCache[filename];
1918
if (cached == null) {
20-
return existsCache[filename] = pathExists.sync(filename);
19+
return existsCache[filename] = fs.existsSync(filename);
2120
} else {
2221
return cached;
2322
}

packages/babel-helper-fixtures/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
"dependencies": {
1010
"babel-runtime": "^6.9.0",
1111
"lodash": "^4.2.0",
12-
"path-exists": "^1.0.0",
1312
"try-resolve": "^1.0.0"
1413
}
1514
}

packages/babel-helper-fixtures/src/index.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import pathExists from "path-exists";
21
import resolve from "try-resolve";
32
import path from "path";
43
import fs from "fs";
@@ -132,12 +131,12 @@ export default function get(entryLoc): Array<Suite> {
132131
suite.tests.push(test);
133132

134133
let sourceMappingsLoc = taskDir + "/source-mappings.json";
135-
if (pathExists.sync(sourceMappingsLoc)) {
134+
if (fs.existsSync(sourceMappingsLoc)) {
136135
test.sourceMappings = JSON.parse(readFile(sourceMappingsLoc));
137136
}
138137

139138
let sourceMapLoc = taskDir + "/source-map.json";
140-
if (pathExists.sync(sourceMapLoc)) {
139+
if (fs.existsSync(sourceMapLoc)) {
141140
test.sourceMap = JSON.parse(readFile(sourceMapLoc));
142141
}
143142
}
@@ -162,7 +161,7 @@ export function multiple(entryLoc, ignore?: Array<string>) {
162161
}
163162

164163
export function readFile(filename) {
165-
if (pathExists.sync(filename)) {
164+
if (fs.existsSync(filename)) {
166165
let file = _.trimEnd(fs.readFileSync(filename, "utf8"));
167166
file = file.replace(/\r\n/g, "\n");
168167
return file;

packages/babel-register/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
"home-or-tmp": "^2.0.0",
1515
"lodash": "^4.2.0",
1616
"mkdirp": "^0.5.1",
17-
"path-exists": "^1.0.0",
1817
"source-map-support": "^0.4.2"
1918
}
2019
}

0 commit comments

Comments
 (0)