Replace path-exists with fs.existsSync (#4731)

It's not deprecated anymore, see nodejs/node#8364
This commit is contained in:
Simen Bekkhus
2016-10-17 20:31:49 +02:00
committed by Henry Zhu
parent 05bdd4822a
commit 9c2794dc85
11 changed files with 14 additions and 24 deletions

View File

@@ -17,7 +17,6 @@
"glob": "^5.0.5",
"lodash": "^4.2.0",
"output-file-sync": "^1.1.0",
"path-exists": "^1.0.0",
"path-is-absolute": "^1.0.0",
"slash": "^1.0.0",
"source-map": "^0.5.0",

View File

@@ -1,5 +1,4 @@
let outputFileSync = require("output-file-sync");
let pathExists = require("path-exists");
let slash = require("slash");
let path = require("path");
let util = require("./util");
@@ -45,7 +44,7 @@ module.exports = function (commander, filenames) {
}
function handle(filename) {
if (!pathExists.sync(filename)) return;
if (!fs.existsSync(filename)) return;
let stat = fs.statSync(filename);

View File

@@ -1,5 +1,4 @@
let convertSourceMap = require("convert-source-map");
let pathExists = require("path-exists");
let sourceMap = require("source-map");
let slash = require("slash");
let path = require("path");
@@ -109,7 +108,7 @@ module.exports = function (commander, filenames, opts) {
results = [];
_.each(filenames, function (filename) {
if (!pathExists.sync(filename)) return;
if (!fs.existsSync(filename)) return;
let stat = fs.statSync(filename);
if (stat.isDirectory()) {

View File

@@ -3,7 +3,7 @@
require("babel-core");
let pathExists = require("path-exists");
let fs = require("fs");
let commander = require("commander");
let kebabCase = require("lodash/kebabCase");
let options = require("babel-core").options;
@@ -70,7 +70,7 @@ let filenames = commander.args.reduce(function (globbed, input) {
filenames = uniq(filenames);
each(filenames, function (filename) {
if (!pathExists.sync(filename)) {
if (!fs.existsSync(filename)) {
errors.push(filename + " doesn't exist");
}
});

View File

@@ -7,7 +7,6 @@ let child = require("child_process");
let path = require("path");
let chai = require("chai");
let fs = require("fs");
let pathExists = require("path-exists");
let _ = require("lodash");
let fixtureLoc = path.join(__dirname, "fixtures");
@@ -25,7 +24,7 @@ let pluginLocs = [
let readDir = function (loc) {
let files = {};
if (pathExists.sync(loc)) {
if (fs.existsSync(loc)) {
_.each(readdir(loc), function (filename) {
files[filename] = helper.readFile(path.join(loc, filename));
});
@@ -130,7 +129,7 @@ let buildTest = function (binName, testName, opts) {
let clear = function () {
process.chdir(__dirname);
if (pathExists.sync(tmpLoc)) rimraf.sync(tmpLoc);
if (fs.existsSync(tmpLoc)) rimraf.sync(tmpLoc);
fs.mkdirSync(tmpLoc);
process.chdir(tmpLoc);
};
@@ -150,11 +149,11 @@ _.each(fs.readdirSync(fixtureLoc), function (binName) {
};
let optionsLoc = path.join(testLoc, "options.json");
if (pathExists.sync(optionsLoc)) _.merge(opts, require(optionsLoc));
if (fs.existsSync(optionsLoc)) _.merge(opts, require(optionsLoc));
_.each(["stdout", "stdin", "stderr"], function (key) {
let loc = path.join(testLoc, key + ".txt");
if (pathExists.sync(loc)) {
if (fs.existsSync(loc)) {
opts[key] = helper.readFile(loc);
} else {
opts[key] = opts[key] || "";
@@ -165,7 +164,7 @@ _.each(fs.readdirSync(fixtureLoc), function (binName) {
opts.inFiles = readDir(path.join(testLoc, "in-files"));
let babelrcLoc = path.join(testLoc, ".babelrc");
if (pathExists.sync(babelrcLoc)) {
if (fs.existsSync(babelrcLoc)) {
// copy .babelrc file to tmp directory
opts.inFiles[".babelrc"] = helper.readFile(babelrcLoc);
}