Skip to content

Commit

Permalink
Update sourcebit.js
Browse files Browse the repository at this point in the history
  • Loading branch information
eduardoboucas committed Feb 25, 2020
1 parent 422e39e commit ece87e3
Showing 1 changed file with 1 addition and 40 deletions.
41 changes: 1 addition & 40 deletions lib/sourcebit.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,46 +160,7 @@ class Sourcebit {
}

async transform() {
const initialData = {
files: [],
models: [],
objects: []
};

let queue = Promise.resolve(initialData);

this.pluginBlocks.forEach(({ _isBootstrapped, options }, index) => {
if (!_isBootstrapped) return data;

queue = queue.then(data => {
const plugin = this.pluginModules[index];
const pluginName = this.getNameOfPluginAtIndex(index);
const { defaults, overrides } = this.parsePluginOptions(plugin);

if (typeof plugin.transform === "function") {
return plugin.transform({
data,
debug: this.getDebugMethodForPlugin(pluginName),
getPluginContext: this.getContextForNamespace.bind(
this,
pluginName
),
log: this.logFromPlugin.bind(this, pluginName),
options: Object.assign({}, defaults, options, overrides)
});
}

return data;
});
});

const data = await queue;

if (Array.isArray(data.files)) {
await this.writeFiles(data.files);
}

return data;

}

writeFiles(files) {
Expand Down

0 comments on commit ece87e3

Please sign in to comment.