Added Eslint and husky (#1062)

This commit is contained in:
aashna27
2019-05-11 20:09:15 +05:30
committed by Jeffrey Warren
parent 0c3d7be7e2
commit c784de0c19
203 changed files with 3288 additions and 3250 deletions

View File

@@ -1,37 +1,37 @@
module.exports = function runInBrowserContext(input, callback, step, options) {
// to ignore this from getting browserified
const puppeteer = eval('require')('puppeteer');
// to ignore this from getting browserified
const puppeteer = eval('require')('puppeteer');
//Stripped down version of options which is serializable
var minOptions = require("lodash").cloneDeep(options);
minOptions.step = options.step.name;
//Stripped down version of options which is serializable
var minOptions = require('lodash').cloneDeep(options);
minOptions.step = options.step.name;
var obj = { input: input, modOptions: minOptions }
var obj = { input: input, modOptions: minOptions };
puppeteer.launch({headless: true, args:['--no-sandbox', '--disable-setuid-sandbox']}).then(function(browser) {
browser.newPage().then(page => {
/* Maybe there is a better way to this, loading the page coz localstorage API
puppeteer.launch({headless: true, args:['--no-sandbox', '--disable-setuid-sandbox']}).then(function(browser) {
browser.newPage().then(page => {
/* Maybe there is a better way to this, loading the page coz localstorage API
is not available otherwise */
page.goto("https://google.com").then(() => {
page.addScriptTag({ path: require('path').join(__dirname, '../../../dist/image-sequencer.js') }).then(() => {
page.evaluate((options) => {
return new Promise((resolve, reject) => {
var sequencer = ImageSequencer();
sequencer.loadImage(options.input.src);
sequencer.addSteps(options.modOptions.step, options.modOptions);
sequencer.run(function cb(out) {
resolve(sequencer.steps[1].output.src)
});
})
}, obj).then(el => {
browser.close().then(() => {
step.output = { src: el, format: input.format };
callback();
});
});
})
page.goto('https://google.com').then(() => {
page.addScriptTag({ path: require('path').join(__dirname, '../../../dist/image-sequencer.js') }).then(() => {
page.evaluate((options) => {
return new Promise((resolve, reject) => {
var sequencer = ImageSequencer();
sequencer.loadImage(options.input.src);
sequencer.addSteps(options.modOptions.step, options.modOptions);
sequencer.run(function cb(out) {
resolve(sequencer.steps[1].output.src);
});
});
}, obj).then(el => {
browser.close().then(() => {
step.output = { src: el, format: input.format };
callback();
});
});
});
});
});
}
});
};