Skip to content
This repository has been archived by the owner on Feb 22, 2020. It is now read-only.

Commit

Permalink
chore(dependencies): upgrade fs-extra
Browse files Browse the repository at this point in the history
  • Loading branch information
evshiron committed May 6, 2017
1 parent 0b6b8ac commit 2a6a153
Show file tree
Hide file tree
Showing 11 changed files with 50 additions and 53 deletions.
4 changes: 2 additions & 2 deletions package.json
Expand Up @@ -27,7 +27,7 @@
"devDependencies": {
"@types/debug": "0.0.29",
"@types/es6-shim": "^0.31.32",
"@types/fs-extra-promise": "0.0.32",
"@types/fs-extra": "^3.0.0",
"@types/node": "^7.0.5",
"@types/progress": "^1.1.28",
"@types/request": "0.0.41",
Expand All @@ -46,7 +46,7 @@
"7zip-bin": "^2.0.4",
"debug": "^2.6.1",
"dir-compare": "^1.3.0",
"fs-extra-promise": "^0.4.1",
"fs-extra": "^3.0.1",
"globby": "^6.1.0",
"plist": "^2.0.1",
"progress": "^1.1.8",
Expand Down
48 changes: 23 additions & 25 deletions src/lib/Builder.ts
Expand Up @@ -2,7 +2,7 @@
import { dirname, basename, resolve } from 'path';

import * as semver from 'semver';
import { ensureDirAsync, emptyDir, readFileAsync, readJsonAsync, writeFileAsync, copyAsync, removeAsync, createReadStream, createWriteStream, renameAsync } from 'fs-extra-promise';
import { ensureDir, emptyDir, readFile, readJson, writeFile, copy, remove, createReadStream, createWriteStream, rename } from 'fs-extra';
import * as Bluebird from 'bluebird';

const debug = require('debug')('build:builder');
Expand Down Expand Up @@ -107,7 +107,7 @@ export class Builder {
}
else {

const pkg: any = await readJsonAsync(resolve(this.dir, this.options.chromeApp ? 'manifest.json' : 'package.json'));
const pkg: any = await readJson(resolve(this.dir, this.options.chromeApp ? 'manifest.json' : 'package.json'));
const config = new BuildConfig(pkg);

debug('in build', 'config', config);
Expand Down Expand Up @@ -155,14 +155,14 @@ export class Builder {
}

protected readPlist(path: string): Promise<any> {
return readFileAsync(path, {
return readFile(path, {
encoding: 'utf-8',
})
.then(data => plist.parse(data));
}

protected writePlist(path: string, p: any) {
return writeFileAsync(path, plist.build(p));
return writeFile(path, plist.build(p));
}

protected updateWinResources(targetDir: string, appRoot: string, pkg: any, config: BuildConfig) {
Expand Down Expand Up @@ -190,7 +190,7 @@ export class Builder {
const src = resolve(targetDir, 'nw.exe');
const dest = resolve(targetDir, `${ config.win.versionStrings.ProductName }.exe`);

return renameAsync(src, dest);
return rename(src, dest);

}

Expand Down Expand Up @@ -218,7 +218,7 @@ export class Builder {
return;
}

await copyAsync(resolve(this.dir, config.mac.icon), path);
await copy(resolve(this.dir, config.mac.icon), path);

}

Expand All @@ -234,7 +234,7 @@ export class Builder {

// Different versions has different encodings for `InforPlist.strings`.
// We determine encoding by evaluating bytes of `CF` here.
const data = await readFileAsync(path);
const data = await readFile(path);
const encoding = data.indexOf(Buffer.from('43004600', 'hex')) >= 0
? 'ucs2' : 'utf-8';

Expand All @@ -257,7 +257,7 @@ export class Builder {
}
});

await writeFileAsync(path, Buffer.from(newStrings, encoding));
await writeFile(path, Buffer.from(newStrings, encoding));

}

Expand All @@ -268,7 +268,7 @@ export class Builder {
const src = resolve(targetDir, 'nwjs.app');
const dest = resolve(targetDir, `${ config.mac.displayName }.app`);

return renameAsync(src, dest);
return rename(src, dest);

}

Expand All @@ -277,7 +277,7 @@ export class Builder {
const src = resolve(targetDir, 'nw');
const dest = resolve(targetDir, `${ pkg.name }`);

return renameAsync(src, dest);
return rename(src, dest);

}

Expand Down Expand Up @@ -349,7 +349,7 @@ export class Builder {
await compress(this.dir, files, 'zip', nwFile);
const executable = await findExecutable(platform, targetDir);
await this.combineExecutable(executable, nwFile);
await removeAsync(nwFile);
await remove(nwFile);
break;
case 'darwin':
case 'osx':
Expand All @@ -373,7 +373,7 @@ export class Builder {

// Here we overwrite `package.json` with a stripped one.

await writeFileAsync(resolve(appRoot, 'package.json'), (() => {
await writeFile(resolve(appRoot, 'package.json'), (() => {

const json: any = {};

Expand Down Expand Up @@ -411,7 +411,7 @@ export class Builder {
const src = await findFFmpeg(platform, ffmpegDir);
const dest = await findFFmpeg(platform, targetDir);

await copyAsync(src, dest);
await copy(src, dest);

}

Expand Down Expand Up @@ -447,13 +447,13 @@ export class Builder {
})).make();

const script = await tmpName();
await writeFileAsync(script, data);
await writeFile(script, data);

await nsisBuild(toDir, script, {
mute: this.options.mute,
});

await removeAsync(script);
await remove(script);

await versionInfo.addUpdater(toVersion, fromVersion, arch, diffNsis);

Expand All @@ -478,19 +478,17 @@ export class Builder {
}
})());

await new Promise((resolve, reject) => {
emptyDir(targetDir, err => err ? reject(err) : resolve());
});
await emptyDir(targetDir);

await copyAsync(runtimeRoot, targetDir, {
await copy(runtimeRoot, targetDir, {
//dereference: true,
});

if(config.ffmpegIntegration) {
await this.integrateFFmpeg(platform, arch, targetDir, pkg, config);
}

await ensureDirAsync(appRoot);
await ensureDir(appRoot);

// Copy before refining might void the effort.

Expand Down Expand Up @@ -525,7 +523,7 @@ export class Builder {

const targetArchive = resolve(dirname(sourceDir), `${ basename(sourceDir) }.${ type }`);

await removeAsync(targetArchive);
await remove(targetArchive);

const files = await globby([ '**/*' ], {
cwd: sourceDir,
Expand Down Expand Up @@ -575,13 +573,13 @@ export class Builder {
})).make();

const script = await tmpName();
await writeFileAsync(script, data);
await writeFile(script, data);

await nsisBuild(sourceDir, script, {
mute: this.options.mute,
});

await removeAsync(script);
await remove(script);

await versionInfo.addVersion(pkg.version, '', sourceDir);
await versionInfo.addInstaller(pkg.version, arch, targetNsis);
Expand Down Expand Up @@ -640,13 +638,13 @@ export class Builder {
})).make();

const script = await tmpName();
await writeFileAsync(script, data);
await writeFile(script, data);

await nsisBuild(sourceDir, script, {
mute: this.options.mute,
});

await removeAsync(script);
await remove(script);

await versionInfo.addVersion(pkg.version, '', sourceDir);
await versionInfo.addInstaller(pkg.version, arch, targetNsis);
Expand Down
1 change: 0 additions & 1 deletion src/lib/FFmpegDownloader.ts
Expand Up @@ -3,7 +3,6 @@ import { dirname, basename, resolve } from 'path';

import * as request from 'request';
import * as ProgressBar from 'progress';
import { ensureDirSync, exists, writeFile } from 'fs-extra-promise';

const debug = require('debug')('build:ffmpegDownloader');
const progress = require('request-progress');
Expand Down
8 changes: 4 additions & 4 deletions src/lib/Runner.ts
Expand Up @@ -2,7 +2,7 @@
import { resolve } from 'path';
import { spawn } from 'child_process';

import { copyAsync, readJsonAsync, chmodAsync } from 'fs-extra-promise';
import { copy, readJson, chmod } from 'fs-extra';

const debug = require('debug')('build:runner');

Expand Down Expand Up @@ -49,7 +49,7 @@ export class Runner {
? (this.options.x86 ? 'ia32' : 'x64')
: process.arch;

const pkg: any = await readJsonAsync(resolve(this.args[0], this.options.chromeApp ? 'manifest.json' : 'package.json'));
const pkg: any = await readJson(resolve(this.args[0], this.options.chromeApp ? 'manifest.json' : 'package.json'));
const config = new BuildConfig(pkg);

debug('in run', 'config', config);
Expand Down Expand Up @@ -87,7 +87,7 @@ export class Runner {

const executable = await findExecutable(platform, runtimeDir);

await chmodAsync(executable, 0o555);
await chmod(executable, 0o555);

if(!this.options.mute) {
console.info('Launching NW.js app...');
Expand Down Expand Up @@ -138,7 +138,7 @@ export class Runner {
const src = await findFFmpeg(platform, ffmpegDir);
const dest = await findFFmpeg(platform, runtimeDir);

await copyAsync(src, dest);
await copy(src, dest);

}

Expand Down
4 changes: 2 additions & 2 deletions src/lib/common/DownloaderBase.ts
Expand Up @@ -3,7 +3,7 @@ import { dirname, basename, resolve } from 'path';

import * as request from 'request';
import * as ProgressBar from 'progress';
import { ensureDirSync, exists, lstatAsync, writeFile } from 'fs-extra-promise';
import { ensureDirSync, exists, lstat, writeFile } from 'fs-extra';

const debug = require('debug')('build:downloader');
const progress = require('request-progress');
Expand Down Expand Up @@ -100,7 +100,7 @@ export abstract class DownloaderBase {
}

protected getLocalSize(path: string): Promise<number> {
return lstatAsync(path)
return lstat(path)
.then(stat => stat.size);
}

Expand Down
6 changes: 3 additions & 3 deletions src/lib/common/NsisVersionInfo.ts
Expand Up @@ -2,7 +2,7 @@
import { basename, dirname, relative } from 'path';
import { createHash } from 'crypto';

import { exists, readJsonAsync, writeJsonAsync, createReadStream } from 'fs-extra-promise';
import { exists, readJson, writeJson, createReadStream } from 'fs-extra';
import * as semver from 'semver';

interface IInstaller {
Expand Down Expand Up @@ -134,14 +134,14 @@ export class NsisVersionInfo {
}

public async save() {
await writeJsonAsync(this.path, this.data);
await writeJson(this.path, this.data);
}

protected async getData() {

if(!this.data) {
this.data = (await new Promise((resolve, reject) => exists(this.path, resolve)))
? await readJsonAsync(this.path)
? await readJson(this.path)
: {
latest: undefined,
versions: [],
Expand Down
2 changes: 1 addition & 1 deletion src/lib/nsis-gen/NsisComposer.ts
@@ -1,7 +1,7 @@

import { relative, resolve, win32 } from 'path';

import { readdirAsync, lstatAsync } from 'fs-extra-promise';
import { readdir, lstat } from 'fs-extra';

import { fixWindowsVersion } from '../util';

Expand Down
6 changes: 3 additions & 3 deletions src/lib/util/archive.ts
@@ -1,7 +1,7 @@

import { dirname, basename, join, resolve, normalize } from 'path';

import { removeAsync, writeFileAsync } from 'fs-extra-promise';
import { remove, writeFile } from 'fs-extra';
import { path7za } from '7zip-bin';

const debug = require('debug')('build:archive');
Expand Down Expand Up @@ -43,7 +43,7 @@ async function extractTarGz(archive: string, dest: string = dirname(archive), op

await extract(tar, dest);

await removeAsync(tar);
await remove(tar);

return dest;

Expand Down Expand Up @@ -80,7 +80,7 @@ export async function compress(dir: string, files: string[], type: string, archi

debug('in compress', 'listfiles', listfiles);

await writeFileAsync(listfiles, files.map(file => normalize(file)).join('\r\n'));
await writeFile(listfiles, files.map(file => normalize(file)).join('\r\n'));

const { code, signal } = await spawnAsync(path7za, [ 'a', `-t${ type }`, resolve(archive), `@${ resolve(listfiles) }` ], {
cwd: dir,
Expand Down
6 changes: 3 additions & 3 deletions src/lib/util/index.ts
Expand Up @@ -4,7 +4,7 @@ import { spawn, exec } from 'child_process';

import * as tmp from 'tmp';
tmp.setGracefulCleanup();
import { lstatAsync, ensureDirAsync, readFileAsync, outputFileAsync } from 'fs-extra-promise';
import { lstat, ensureDir, readFile, outputFile } from 'fs-extra';

const debug = require('debug')('build:util');
const globby = require('globby');
Expand Down Expand Up @@ -231,13 +231,13 @@ export function fixWindowsVersion(version: string, build: number = 0) {

export async function copyFileAsync(src: string, dest: string) {

const stats = await lstatAsync(src);
const stats = await lstat(src);

if(stats.isDirectory() || stats.isSymbolicLink()) {
//await ensureDirAsync(dest);
}
else {
await outputFileAsync(dest, await readFileAsync(src));
await outputFile(dest, await readFile(src));
}

}
Expand Down

0 comments on commit 2a6a153

Please sign in to comment.