Skip to content

Commit

Permalink
chore: replace pify with util.promisify
Browse files Browse the repository at this point in the history
  • Loading branch information
malept committed Jun 15, 2019
1 parent 4e179c6 commit b94692c
Show file tree
Hide file tree
Showing 14 changed files with 20 additions and 33 deletions.
2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@
"open": "^6.0.0",
"ora": "^3.0.0",
"parse-author": "^2.0.0",
"pify": "^4.0.0",
"pretty-ms": "^5.0.0",
"resolve-package": "^1.0.1",
"s3": "^4.4.0",
Expand Down Expand Up @@ -113,7 +112,6 @@
"@types/mocha": "^5.2.7",
"@types/node": "^12.0.8",
"@types/node-fetch": "^2.3.6",
"@types/pify": "^3.0.1",
"@types/pretty-ms": "^4.0.0",
"@types/proxyquire": "^1.3.28",
"@types/semver": "^6.0.0",
Expand Down
1 change: 0 additions & 1 deletion packages/api/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
"log-symbols": "^3.0.0",
"node-fetch": "^2.6.0",
"nugget": "^2.0.1",
"pify": "^4.0.0",
"resolve-package": "^1.0.1",
"semver": "^6.1.1",
"source-map-support": "^0.5.12",
Expand Down
4 changes: 2 additions & 2 deletions packages/api/core/src/api/install.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import fetch from 'node-fetch';
import fs from 'fs-extra';
import os from 'os';
import path from 'path';
import pify from 'pify';
import { promisify } from 'util';
import semver from 'semver';

import DMGInstaller from '@electron-forge/installer-dmg';
Expand Down Expand Up @@ -158,7 +158,7 @@ export default async ({
resume: true,
strictSSL: true,
};
await pify(nugget)(targetAsset.browser_download_url, nuggetOpts);
await promisify(nugget)(targetAsset.browser_download_url, nuggetOpts);
}

await asyncOra('Installing Application', async (installSpinner) => {
Expand Down
8 changes: 4 additions & 4 deletions packages/api/core/src/api/package.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import debug from 'debug';
import fs from 'fs-extra';
import { getHostArch } from '@electron/get';
import glob from 'glob';
import path from 'path';
import pify from 'pify';
import packager from 'electron-packager';
import path from 'path';
import { promisify } from 'util';

import getForgeConfig from '../util/forge-config';
import { runHook } from '../util/hook';
Expand Down Expand Up @@ -53,7 +53,7 @@ function sequentialHooks(hooks: Function[]) {
const done = args[args.length - 1];
const passedArgs = args.splice(0, args.length - 1);
for (const hook of hooks) {
await pify(hook)(...passedArgs);
await promisify(hook)(...passedArgs);
}
done();
}] as [(...args: any[]) => Promise<void>];
Expand Down Expand Up @@ -119,7 +119,7 @@ export default async ({
prepareCounter += 1;
prepareSpinner = ora(`Preparing to Package Application for arch: ${(prepareCounter === 2 ? 'armv7l' : 'x64').cyan}`).start();
}
const bins = await pify(glob)(path.join(buildPath, '**/.bin/**/*'));
const bins = await promisify(glob)(path.join(buildPath, '**/.bin/**/*'));
for (const bin of bins) {
await fs.remove(bin);
}
Expand Down
4 changes: 2 additions & 2 deletions packages/api/core/src/util/linux-installer.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { promisify } from 'util';
import { spawnSync } from 'child_process';
import pify from 'pify';
import sudoPrompt from 'sudo-prompt';

const which = async (type: string, prog: string, promise: () => Promise<any>) => {
Expand All @@ -10,6 +10,6 @@ const which = async (type: string, prog: string, promise: () => Promise<any>) =>
}
};

export const sudo = (type: string, prog: string, args: string) => which(type, prog, () => pify(sudoPrompt.exec)(`${prog} ${args}`, { name: 'Electron Forge' }));
export const sudo = (type: string, prog: string, args: string) => which(type, prog, () => promisify(sudoPrompt.exec)(`${prog} ${args}`, { name: 'Electron Forge' }));

export default which;
1 change: 0 additions & 1 deletion packages/installer/darwin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
"@electron-forge/async-ora": "6.0.0-beta.39",
"@electron-forge/installer-base": "6.0.0-beta.39",
"fs-extra": "^7.0.0",
"pify": "^4.0.0",
"sudo-prompt": "^9.0.0"
}
}
6 changes: 3 additions & 3 deletions packages/installer/darwin/src/InstallerDarwin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import InstallerBase, { InstallerOptions } from '@electron-forge/installer-base'

import fs from 'fs-extra';
import path from 'path';
import pify from 'pify';
import { promisify } from 'util';
import sudo from 'sudo-prompt';
import { exec } from 'child_process';

Expand All @@ -30,9 +30,9 @@ export default abstract class InstallerDarwin extends InstallerBase {

const moveCommand = `${copyInstead ? 'cp -r' : 'mv'} "${appPath}" "${targetApplicationPath}"`;
if (writeAccess) {
await pify(exec)(moveCommand);
await promisify(exec)(moveCommand);
} else {
await pify(sudo.exec)(moveCommand, {
await promisify(sudo.exec)(moveCommand, {
name: 'Electron Forge',
});
}
Expand Down
1 change: 0 additions & 1 deletion packages/installer/linux/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
},
"dependencies": {
"@electron-forge/installer-base": "6.0.0-beta.39",
"pify": "^4.0.0",
"sudo-prompt": "^9.0.0"
}
}
4 changes: 2 additions & 2 deletions packages/installer/linux/src/InstallerLinux.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import InstallerBase, { InstallerOptions } from '@electron-forge/installer-base';

import { spawnSync } from 'child_process';
import pify from 'pify';
import { promisify } from 'util';
import sudoPrompt from 'sudo-prompt';

export { InstallerOptions };
Expand All @@ -18,6 +18,6 @@ export default abstract class InstallerLinux extends InstallerBase {
sudo = (type: string, program: string, args: string) => this.which(
type,
program,
() => pify(sudoPrompt.exec)(`${program} ${args}`, { name: 'Electron Forge' }),
() => promisify(sudoPrompt.exec)(`${program} ${args}`, { name: 'Electron Forge' }),
)
}
5 changes: 2 additions & 3 deletions packages/maker/appx/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,9 @@
"@electron-forge/shared-types": "6.0.0-beta.39",
"cross-spawn": "^6.0.4",
"fs-extra": "^7.0.0",
"parse-author": "^2.0.0",
"pify": "^4.0.0"
"parse-author": "^2.0.0"
},
"optionalDependencies": {
"electron-windows-store": "^2.1.0"
}
}
}
3 changes: 1 addition & 2 deletions packages/maker/flatpak/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@
"dependencies": {
"@electron-forge/maker-base": "6.0.0-beta.39",
"@electron-forge/shared-types": "6.0.0-beta.39",
"fs-extra": "^7.0.0",
"pify": "^4.0.0"
"fs-extra": "^7.0.0"
},
"optionalDependencies": {
"@malept/electron-installer-flatpak": "^0.10.0"
Expand Down
5 changes: 2 additions & 3 deletions packages/maker/zip/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
"@electron-forge/maker-base": "6.0.0-beta.39",
"@electron-forge/shared-types": "6.0.0-beta.39",
"cross-zip": "^2.1.5",
"fs-extra": "^7.0.0",
"pify": "^4.0.0"
"fs-extra": "^7.0.0"
}
}
}
4 changes: 2 additions & 2 deletions packages/maker/zip/src/MakerZIP.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import MakerBase, { MakerOptions } from '@electron-forge/maker-base';
import { ForgePlatform } from '@electron-forge/shared-types';

import path from 'path';
import pify from 'pify';
import { promisify } from 'util';

export type MakerZIPConfig = {};

Expand Down Expand Up @@ -30,7 +30,7 @@ export default class MakerZIP extends MakerBase<MakerZIPConfig> {
const zipPath = path.resolve(makeDir, `${path.basename(dir)}-${packageJSON.version}.zip`);

await this.ensureFile(zipPath);
await pify(zip)(zipDir, zipPath);
await promisify(zip)(zipDir, zipPath);

return [zipPath];
}
Expand Down
5 changes: 0 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1123,11 +1123,6 @@
resolved "https://registry.yarnpkg.com/@types/node/-/node-12.0.8.tgz#551466be11b2adc3f3d47156758f610bd9f6b1d8"
integrity sha512-b8bbUOTwzIY3V5vDTY1fIJ+ePKDUBqt2hC2woVGotdQQhG/2Sh62HOKHrT7ab+VerXAcPyAiTEipPu/FsreUtg==

"@types/pify@^3.0.1":
version "3.0.2"
resolved "https://registry.yarnpkg.com/@types/pify/-/pify-3.0.2.tgz#1bc75dac43e31dba981c37e0a08edddc1b49cd39"
integrity sha512-a5AKF1/9pCU3HGMkesgY6LsBdXHUY3WU+I2qgpU0J+I8XuJA1aFr59eS84/HP0+dxsyBSNbt+4yGI2adUpHwSg==

"@types/pretty-ms@^4.0.0":
version "4.0.0"
resolved "https://registry.yarnpkg.com/@types/pretty-ms/-/pretty-ms-4.0.0.tgz#5e5177b9e447fbc8446e6fd2b09aea045971f11d"
Expand Down

0 comments on commit b94692c

Please sign in to comment.