Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: update fs-extra package #193

Merged
merged 1 commit into from
Feb 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/merge-reports/data-tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
const path = require('path');
const _ = require('lodash');
const Promise = require('bluebird');
const fs = Promise.promisifyAll(require('fs-extra'));
const fs = require('fs-extra');
const {isSkippedStatus} = require('../common-utils');
const {findNode, setStatusForBranch} = require('../static/modules/utils');
const {getDataFrom, getStatNameForStatus, getImagePaths} = require('./utils');
Expand Down Expand Up @@ -149,7 +149,7 @@ module.exports = class DataTree {
_.isNumber(newAttempt) ? imgPath.replace(/\d+(?=.png$)/, newAttempt) : imgPath
);

await fs.moveAsync(srcImgPath, destImgPath, {overwrite: true});
await fs.move(srcImgPath, destImgPath, {overwrite: true});
});
}

Expand Down
8 changes: 4 additions & 4 deletions lib/merge-reports/report-builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
const path = require('path');
const _ = require('lodash');
const Promise = require('bluebird');
const fs = Promise.promisifyAll(require('fs-extra'));
const fs = require('fs-extra');
const chalk = require('chalk');
const DataTree = require('./data-tree');
const serverUtils = require('../server-utils');
Expand Down Expand Up @@ -50,7 +50,7 @@ module.exports = class ReportBuilder {
const srcDataPath = path.resolve(from, dataName);
const destDataPath = path.resolve(to, dataName);

await fs.moveAsync(srcDataPath, destDataPath);
await fs.move(srcDataPath, destDataPath);
});
}

Expand All @@ -63,7 +63,7 @@ module.exports = class ReportBuilder {
};

async function moveContentToReportDir({from, to}) {
const files = await fs.readdirAsync(path.resolve(from));
const files = await fs.readdir(path.resolve(from));

await Promise.map(files, async (fileName) => {
if (fileName === 'data.js') {
Expand All @@ -73,6 +73,6 @@ async function moveContentToReportDir({from, to}) {
const srcFilePath = path.resolve(from, fileName);
const destFilePath = path.resolve(to, fileName);

await fs.moveAsync(srcFilePath, destFilePath, {overwrite: true});
await fs.move(srcFilePath, destFilePath, {overwrite: true});
});
}
2 changes: 0 additions & 2 deletions lib/plugin-adapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ const utils = require('./server-utils');
const cliCommands = require('./cli-commands');
const PluginApi = require('./plugin-api');

Promise.promisifyAll(require('fs-extra'));

module.exports = class PluginAdapter {
static create(tool, opts, toolName) {
return new this(tool, opts, toolName);
Expand Down
6 changes: 3 additions & 3 deletions lib/report-builder-factory/report-builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,8 @@ module.exports = class ReportBuilder {
}

saveDataFileAsync() {
return fs.mkdirsAsync(this._pluginConfig.path)
.then(() => this._saveDataFile(fs.writeFileAsync));
return fs.mkdirs(this._pluginConfig.path)
.then(() => this._saveDataFile(fs.writeFile));
}

saveDataFileSync() {
Expand Down Expand Up @@ -231,7 +231,7 @@ module.exports = class ReportBuilder {
const from = path.resolve(__dirname, '../static', fileName);
const to = path.join(this._pluginConfig.path, fileName);

return fs.copyAsync(from, to);
return fs.copy(from, to);
});
}

Expand Down
2 changes: 1 addition & 1 deletion lib/reporter-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,5 +95,5 @@ exports.saveBase64Screenshot = (testResult, reportPath) => {
const destPath = utils.getCurrentAbsolutePath(testResult, reportPath);

return utils.makeDirFor(destPath)
.then(() => fs.writeFileAsync(destPath, new Buffer(testResult.screenshot.base64, 'base64'), 'base64'));
.then(() => fs.writeFile(destPath, new Buffer(testResult.screenshot.base64, 'base64'), 'base64'));
};
4 changes: 2 additions & 2 deletions lib/server-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ function createPath(kind, result, stateName) {

function copyImageAsync(srcPath, destPath) {
return makeDirFor(destPath)
.then(() => fs.copyAsync(srcPath, destPath));
.then(() => fs.copy(srcPath, destPath));
}

/**
Expand All @@ -61,7 +61,7 @@ function saveDiff(result, destPath) {
* @param {String} destPath
*/
function makeDirFor(destPath) {
return fs.mkdirsAsync(path.dirname(destPath));
return fs.mkdirs(path.dirname(destPath));
}

const logger = _.pick(console, ['log', 'warn', 'error']);
Expand Down
20 changes: 13 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"body-parser": "^1.18.2",
"chalk": "^1.1.3",
"express": "^4.16.2",
"fs-extra": "^2.1.2",
"fs-extra": "^7.0.1",
"gemini-configparser": "^1.0.0",
"json-stringify-safe": "^5.0.1",
"lodash": "^4.17.4",
Expand Down
6 changes: 3 additions & 3 deletions test/gemini.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ describe('lib/gemini', () => {
sandbox.spy(PluginAdapter.prototype, 'addCliCommands');
sandbox.spy(PluginAdapter.prototype, 'init');

sandbox.stub(fs, 'mkdirsAsync').resolves();
sandbox.stub(fs, 'writeFileAsync').resolves();
sandbox.stub(fs, 'copyAsync').resolves();
sandbox.stub(fs, 'mkdirs').resolves();
sandbox.stub(fs, 'writeFile').resolves();
sandbox.stub(fs, 'copy').resolves();

sandbox.stub(utils, 'copyImageAsync');
sandbox.stub(utils, 'logPathToHtmlReport');
Expand Down
6 changes: 3 additions & 3 deletions test/hermione.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ describe('lib/hermione', () => {
sandbox.spy(PluginAdapter.prototype, 'addCliCommands');
sandbox.spy(PluginAdapter.prototype, 'init');

sandbox.stub(fs, 'mkdirsAsync').resolves();
sandbox.stub(fs, 'writeFileAsync').resolves();
sandbox.stub(fs, 'copyAsync').resolves();
sandbox.stub(fs, 'mkdirs').resolves();
sandbox.stub(fs, 'writeFile').resolves();
sandbox.stub(fs, 'copy').resolves();

sandbox.stub(utils, 'copyImageAsync');
sandbox.stub(utils, 'getCurrentAbsolutePath');
Expand Down
24 changes: 12 additions & 12 deletions test/lib/merge-reports/data-tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ describe('lib/merge-reports/data-tree', () => {
};

beforeEach(() => {
sandbox.stub(fs, 'moveAsync');
sandbox.stub(fs, 'move');
});

afterEach(() => sandbox.restore());
Expand Down Expand Up @@ -480,7 +480,7 @@ describe('lib/merge-reports/data-tree', () => {
await mkDataTree_(initialData, 'dest-report/path').mergeWith(dataCollection);

assert.neverCalledWith(
fs.moveAsync,
fs.move,
path.resolve('src-report/path', 'screens/yabro/stateName.png'),
path.resolve('dest-report/path', 'screens/yabro/stateName.png'),
);
Expand Down Expand Up @@ -508,7 +508,7 @@ describe('lib/merge-reports/data-tree', () => {

imgPaths.forEach((imgPath) => {
assert.calledWith(
fs.moveAsync,
fs.move,
path.resolve('src-report/path', imgPath),
path.resolve('dest-report/path', imgPath)
);
Expand All @@ -535,7 +535,7 @@ describe('lib/merge-reports/data-tree', () => {

[0, 1].forEach((attempt) => {
assert.calledWith(
fs.moveAsync,
fs.move,
path.resolve('src-report/path', `images/yabro~current_${attempt}.png`),
path.resolve('dest-report/path', `images/yabro~current_${attempt}.png`)
);
Expand Down Expand Up @@ -564,7 +564,7 @@ describe('lib/merge-reports/data-tree', () => {

[0, 1].forEach((attempt) => {
assert.calledWith(
fs.moveAsync,
fs.move,
path.resolve('src-report/path', `images/yabro~current_${attempt}.png`),
path.resolve('dest-report/path', `images/yabro~current_${attempt}.png`)
);
Expand Down Expand Up @@ -594,7 +594,7 @@ describe('lib/merge-reports/data-tree', () => {

[0, 1].forEach((attempt) => {
assert.calledWith(
fs.moveAsync,
fs.move,
path.resolve('src-report/path', `images/yabro~current_${attempt}.png`),
path.resolve('dest-report/path', `images/yabro~current_${attempt}.png`)
);
Expand Down Expand Up @@ -625,7 +625,7 @@ describe('lib/merge-reports/data-tree', () => {
await mkDataTree_(initialData, 'dest-report/path').mergeWith(dataCollection);

assert.calledOnceWith(
fs.moveAsync,
fs.move,
path.resolve('src-report/path', 'images/yabro~current_0.png'),
path.resolve('dest-report/path', 'images/yabro~current_1.png')
);
Expand All @@ -651,7 +651,7 @@ describe('lib/merge-reports/data-tree', () => {
await mkDataTree_(initialData, 'dest-report/path').mergeWith(dataCollection);

assert.calledWith(
fs.moveAsync,
fs.move,
path.resolve('src-report/path', `images/yabro~current_0.png`),
path.resolve('dest-report/path', `images/yabro~current_1.png`)
);
Expand Down Expand Up @@ -679,7 +679,7 @@ describe('lib/merge-reports/data-tree', () => {

[0, 1].forEach((attempt) => {
assert.calledWith(
fs.moveAsync,
fs.move,
path.resolve('src-report/path', `images/yabro~current_${attempt}.png`),
path.resolve('dest-report/path', `images/yabro~current_${attempt + 1}.png`)
);
Expand Down Expand Up @@ -709,7 +709,7 @@ describe('lib/merge-reports/data-tree', () => {
await mkDataTree_(initialData, 'dest-report/path').mergeWith(dataCollection);

assert.calledWith(
fs.moveAsync,
fs.move,
path.resolve('src-report/path', `images/yabro~current_0.png`),
path.resolve('dest-report/path', `images/yabro~current_1.png`)
);
Expand Down Expand Up @@ -738,7 +738,7 @@ describe('lib/merge-reports/data-tree', () => {

[0, 1].forEach((attempt) => {
assert.calledWith(
fs.moveAsync,
fs.move,
path.resolve('src-report/path', `images/yabro~current_${attempt}.png`),
path.resolve('dest-report/path', `images/yabro~current_${attempt + 2}.png`)
);
Expand Down Expand Up @@ -768,7 +768,7 @@ describe('lib/merge-reports/data-tree', () => {
await mkDataTree_(initialData, 'dest-report/path').mergeWith(dataCollection);

assert.calledWith(
fs.moveAsync,
fs.move,
path.resolve('src-report/path', 'images/yabro~current_0.png'),
path.resolve('dest-report/path', 'images/yabro~current_1.png')
);
Expand Down
12 changes: 6 additions & 6 deletions test/lib/merge-reports/report-builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ describe('lib/merge-reports/report-builder', () => {
sandbox.stub(serverUtils, 'require').returns({});
sandbox.stub(serverUtils, 'prepareCommonJSData');
sandbox.stub(serverUtils.logger, 'warn');
sandbox.stub(fs, 'moveAsync');
sandbox.stub(fs, 'move');
sandbox.stub(fs, 'writeFile');
sandbox.stub(fs, 'readdirAsync').resolves([]);
sandbox.stub(fs, 'readdir').resolves([]);

sandbox.stub(DataTree, 'create').returns(Object.create(DataTree.prototype));
sandbox.stub(DataTree.prototype, 'mergeWith').resolves();
Expand All @@ -28,25 +28,25 @@ describe('lib/merge-reports/report-builder', () => {
afterEach(() => sandbox.restore());

it('should move contents of first source report to destination report', async () => {
fs.readdirAsync.resolves(['file-path']);
fs.readdir.resolves(['file-path']);

const srcFilePath = path.resolve('src-report/path-1', 'file-path');
const destFilePath = path.resolve('dest-report/path', 'file-path');

await buildReport_(['src-report/path-1', 'src-report/path-2'], 'dest-report/path');

assert.calledWith(fs.moveAsync, srcFilePath, destFilePath, {overwrite: true});
assert.calledWith(fs.move, srcFilePath, destFilePath, {overwrite: true});
});

it('should not move "data.js" file from first source report to destinatino report', async () => {
fs.readdirAsync.resolves(['file-path', 'data.js']);
fs.readdir.resolves(['file-path', 'data.js']);

const srcDataPath = path.resolve('src-report/path-1', 'data.js');
const destPath = path.resolve('dest-report/path');

await buildReport_(['src-report/path-1', 'src-report/path-2'], 'dest-report/path');

assert.neverCalledWith(fs.moveAsync, srcDataPath, destPath);
assert.neverCalledWith(fs.move, srcDataPath, destPath);
});

it('should not fail if data file does not find in source report path', async () => {
Expand Down
18 changes: 9 additions & 9 deletions test/lib/report-builder-factory/report-builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ describe('ReportBuilder', () => {
};

beforeEach(() => {
sandbox.stub(fs, 'copyAsync').resolves();
sandbox.stub(fs, 'mkdirsAsync').resolves();
sandbox.stub(fs, 'copy').resolves();
sandbox.stub(fs, 'mkdirs').resolves();
sandbox.stub(fs, 'mkdirsSync');
sandbox.stub(fs, 'writeFileAsync').resolves();
sandbox.stub(fs, 'writeFile').resolves();
sandbox.stub(fs, 'writeFileSync');
sandbox.stub(serverUtils, 'prepareCommonJSData');

Expand Down Expand Up @@ -602,7 +602,7 @@ describe('ReportBuilder', () => {
const reportBuilder = mkReportBuilder_({pluginConfig: {path: 'some/report/dir'}});

return reportBuilder.saveDataFileAsync()
.then(() => assert.calledOnceWith(fs.mkdirsAsync, 'some/report/dir'));
.then(() => assert.calledOnceWith(fs.mkdirs, 'some/report/dir'));
});

it('should save data file with tests result asynchronously', () => {
Expand All @@ -612,14 +612,14 @@ describe('ReportBuilder', () => {
const reportBuilder = mkReportBuilder_({pluginConfig: {path: 'some/report/dir'}});

return reportBuilder.saveDataFileAsync()
.then(() => assert.calledWith(fs.writeFileAsync, path.join('some', 'report', 'dir', 'data.js'), 'some data', 'utf8'));
.then(() => assert.calledWith(fs.writeFile, path.join('some', 'report', 'dir', 'data.js'), 'some data', 'utf8'));
});

it('should create report directory before save data file', () => {
const reportBuilder = mkReportBuilder_();

return reportBuilder.saveDataFileAsync()
.then(() => assert.callOrder(fs.mkdirsAsync, fs.writeFileAsync));
.then(() => assert.callOrder(fs.mkdirs, fs.writeFile));
});
});

Expand Down Expand Up @@ -670,9 +670,9 @@ describe('ReportBuilder', () => {

return reportBuilder.save()
.then(() => {
assert.calledWithMatch(fs.copyAsync, 'index.html', path.join('some', 'report', 'dir', 'index.html'));
assert.calledWithMatch(fs.copyAsync, 'report.min.js', path.join('some', 'report', 'dir', 'report.min.js'));
assert.calledWithMatch(fs.copyAsync, 'report.min.css', path.join('some', 'report', 'dir', 'report.min.css'));
assert.calledWithMatch(fs.copy, 'index.html', path.join('some', 'report', 'dir', 'index.html'));
assert.calledWithMatch(fs.copy, 'report.min.js', path.join('some', 'report', 'dir', 'report.min.js'));
assert.calledWithMatch(fs.copy, 'report.min.css', path.join('some', 'report', 'dir', 'report.min.css'));
});
});

Expand Down
Loading