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

refactor(box): remove Bluebird.asCallback #4379

Merged
merged 1 commit into from Jul 11, 2020
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 4 additions & 12 deletions lib/box/file.js
Expand Up @@ -10,24 +10,16 @@ class File {
this.type = type;
}

read(options, callback) {
if (!callback && typeof options === 'function') {
callback = options;
options = {};
}
return readFile(this.source, options).asCallback(callback);
read(options) {
return readFile(this.source, options);
}

readSync(options) {
return readFileSync(this.source, options);
}

stat(options, callback) {
if (!callback && typeof options === 'function') {
callback = options;
}

return stat(this.source).asCallback(callback);
stat(options) {
return stat(this.source);
}

statSync(options) {
Expand Down
9 changes: 2 additions & 7 deletions lib/box/index.js
Expand Up @@ -41,15 +41,10 @@ class Box extends EventEmitter {
const ctx = this.context;

class _File extends File {
render(options, callback) {
if (!callback && typeof options === 'function') {
callback = options;
options = {};
}

render(options) {
return ctx.render.render({
path: this.source
}, options).asCallback(callback);
}, options);
}

renderSync(options) {
Expand Down
26 changes: 0 additions & 26 deletions test/scripts/box/file.js
Expand Up @@ -55,14 +55,6 @@ describe('File', () => {
result.should.eql(body);
});

it('read() - callback', callback => {
file.read((err, content) => {
should.not.exist(err);
content.should.eql(body);
callback();
});
});

it('readSync()', () => {
file.readSync().should.eql(body);
});
Expand All @@ -75,15 +67,6 @@ describe('File', () => {
stats[0].should.eql(stats[1]);
});

it('stat() - callback', callback => {
file.stat((err, fileStats) => {
if (err) return callback(err);

fileStats.should.eql(statSync(file.source));
callback();
});
});

it('statSync()', () => {
file.statSync().should.eql(statSync(file.source));
});
Expand All @@ -93,15 +76,6 @@ describe('File', () => {
result.should.eql(obj);
});

it('render() - callback', callback => {
file.render((err, data) => {
if (err) return callback(err);

data.should.eql(obj);
callback();
});
});

it('renderSync()', () => {
file.renderSync().should.eql(obj);
});
Expand Down