Skip to content

Commit 012b152

Browse files
committed
refactor(generic): replace fs-promise with fs-extra
As of fs-extra 3.0.0, it comes with builtin Promise support, so a wrapper module is no longer necessary. Also comes with a non-deprecated fs.exists method.
1 parent 855c487 commit 012b152

29 files changed

+67
-67
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@
111111
"electron-rebuild": "^1.5.7",
112112
"electron-sudo": "malept/electron-sudo#fix-linux-sudo-detection",
113113
"form-data": "^2.1.4",
114-
"fs-promise": "^2.0.0",
114+
"fs-extra": "^3.0.0",
115115
"github": "^9.0.0",
116116
"glob": "^7.1.1",
117117
"inquirer": "^3.0.1 ",

src/api/import.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import debug from 'debug';
2-
import fs from 'fs-promise';
2+
import fs from 'fs-extra';
33
import inquirer from 'inquirer';
44
import path from 'path';
55
import { spawn as yarnOrNPMSpawn, hasYarn } from 'yarn-or-npm';
@@ -44,7 +44,7 @@ export default async (providedOptions = {}) => {
4444
asyncOra.interactive = interactive;
4545

4646
d(`Attempting to import project in: ${dir}`);
47-
if (!await fs.exists(dir) || !await fs.exists(path.resolve(dir, 'package.json'))) {
47+
if (!await fs.pathExists(dir) || !await fs.pathExists(path.resolve(dir, 'package.json'))) {
4848
throw `We couldn't find a project in: ${dir}`;
4949
}
5050

@@ -194,7 +194,7 @@ export default async (providedOptions = {}) => {
194194
await writeChanges();
195195

196196
await asyncOra('Fixing .gitignore', async () => {
197-
if (await fs.exists(path.resolve(dir, '.gitignore'))) {
197+
if (await fs.pathExists(path.resolve(dir, '.gitignore'))) {
198198
const gitignore = await fs.readFile(path.resolve(dir, '.gitignore'));
199199
if (!gitignore.includes(outDir)) {
200200
await fs.writeFile(path.resolve(dir, '.gitignore'), `${gitignore}\n${outDir}/`);
@@ -204,15 +204,15 @@ export default async (providedOptions = {}) => {
204204

205205
let babelConfig = packageJSON.babel;
206206
const babelPath = path.resolve(dir, '.babelrc');
207-
if (!babelConfig && await fs.exists(babelPath)) {
207+
if (!babelConfig && await fs.pathExists(babelPath)) {
208208
babelConfig = JSON.parse(await fs.readFile(babelPath, 'utf8'));
209209
}
210210

211211
if (babelConfig) {
212212
await asyncOra('Porting original babel config', async () => {
213213
let compileConfig = {};
214214
const compilePath = path.resolve(dir, '.compilerc');
215-
if (await fs.exists(compilePath)) {
215+
if (await fs.pathExists(compilePath)) {
216216
compileConfig = JSON.parse(await fs.readFile(compilePath, 'utf8'));
217217
}
218218

src/api/install.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import 'colors';
22
import debug from 'debug';
33
import fetch from 'node-fetch';
4-
import fs from 'fs-promise';
4+
import fs from 'fs-extra';
55
import inquirer from 'inquirer';
66
import nugget from 'nugget';
77
import os from 'os';
@@ -130,7 +130,7 @@ export default async (providedOptions = {}) => {
130130
const filename = `${pathSafeRepo}-${latestRelease.tag_name}-${targetAsset.name}`;
131131

132132
const fullFilePath = path.resolve(tmpdir, filename);
133-
if (!await fs.exists(fullFilePath) || (await fs.stat(fullFilePath)).size !== targetAsset.size) {
133+
if (!await fs.pathExists(fullFilePath) || (await fs.stat(fullFilePath)).size !== targetAsset.size) {
134134
await fs.mkdirs(tmpdir);
135135

136136
const nuggetOpts = {

src/api/make.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import 'colors';
2-
import fs from 'fs-promise';
2+
import fs from 'fs-extra';
33
import path from 'path';
44

55
import asyncOra from '../util/ora-handler';
@@ -136,7 +136,7 @@ export default async (providedOptions = {}) => {
136136

137137
for (const targetArch of targetArchs) {
138138
const packageDir = path.resolve(outDir, `${appName}-${platform}-${targetArch}`);
139-
if (!(await fs.exists(packageDir))) {
139+
if (!(await fs.pathExists(packageDir))) {
140140
throw new Error(`Couldn't find packaged app at: ${packageDir}`);
141141
}
142142

src/api/package.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import 'colors';
22
import debug from 'debug';
3-
import fs from 'fs-promise';
3+
import fs from 'fs-extra';
44
import glob from 'glob';
55
import path from 'path';
66
import pify from 'pify';

src/electron-forge-make.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import fs from 'fs-promise';
1+
import fs from 'fs-extra';
22
import path from 'path';
33
import program from 'commander';
44

src/electron-forge-package.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import fs from 'fs-promise';
1+
import fs from 'fs-extra';
22
import path from 'path';
33
import program from 'commander';
44

src/electron-forge-publish.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import fs from 'fs-promise';
1+
import fs from 'fs-extra';
22
import path from 'path';
33
import program from 'commander';
44

src/electron-forge-start.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import fs from 'fs-promise';
1+
import fs from 'fs-extra';
22
import path from 'path';
33
import program from 'commander';
44

src/init/init-custom.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import debug from 'debug';
2-
import fs from 'fs-promise';
2+
import fs from 'fs-extra';
33
import glob from 'glob';
44
import resolvePackage from 'resolve-package';
55
import path from 'path';

0 commit comments

Comments
 (0)