Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
draggable === true ? 'style="-webkit-app-region:drag"' : ""
}>
`;
// Disable menu (and refresh shortcuts)
this.browserWindow.setMenu(null);
// Save html
let filepath = tempWrite.sync(html, "swal.html");
this.browserWindow.loadURL("file://" + filepath);
if (isMac) {
// Disable Window Refresh (Cmd+R)
this.browserWindow.on("focus", event => {
globalShortcut.registerAll(
["CommandOrControl+R", "CommandOrControl+Shift+R"],
() => {}
);
});
this.browserWindow.on("blur", event => {
globalShortcut.unregister("CommandOrControl+R");
globalShortcut.unregister("CommandOrControl+Shift+R");
});
test('overwrite option', async t => {
await t.throwsAsync(
moveFile(tempWrite.sync('x'), tempWrite.sync('y'), {overwrite: false}),
/The destination file exists/
);
});
beforeEach(() => {
dbFile = tempWrite.sync(
JSON.stringify({
posts: [{ id: 1 }, { _id: 2 }],
comments: [{ id: 1, post_id: 1 }]
}),
'db.json'
)
routesFile = tempWrite.sync(
JSON.stringify({ '/blog/*': '/$1' }),
'routes.json'
)
++PORT
request = supertest(`http://localhost:${PORT}`)
})
test.serial('getUsage works well', t => {
const file = tempWrite.sync('module.exports = input => input + \'!\'', 'test.js');
usage.getUsage({input: file});
t.true(logged.indexOf('') !== -1);
});
test.serial('getModuleSignature works for functions', t => {
const fileA = tempWrite.sync('module.exports = (a, b) => a + b;', 'a.js');
const fileB = tempWrite.sync('module.exports = () => document.body.innerText = \'Hi\';', 'b.js');
const fileC = tempWrite.sync('module.exports = (a, b, c, d, e) => a;', 'c.js');
t.is(usage.getModuleSignature({input: fileA, name: 'concat'}), 'concat(foo, bar);');
t.is(usage.getModuleSignature({input: fileB, name: 'sayHi'}), 'sayHi();');
t.is(usage.getModuleSignature({input: fileC, name: 'lotsOfArgs'}), 'lotsOfArgs(args...);');
});
t.throws(() => {
moveFile.sync(tempWrite.sync('x'), tempWrite.sync('y'), {overwrite: false});
}, /The destination file exists/);
});
test.serial('getModuleSignature works for functions', t => {
const fileA = tempWrite.sync('module.exports = (a, b) => a + b;', 'a.js');
const fileB = tempWrite.sync('module.exports = () => document.body.innerText = \'Hi\';', 'b.js');
const fileC = tempWrite.sync('module.exports = (a, b, c, d, e) => a;', 'c.js');
t.is(usage.getModuleSignature({input: fileA, name: 'concat'}), 'concat(foo, bar);');
t.is(usage.getModuleSignature({input: fileB, name: 'sayHi'}), 'sayHi();');
t.is(usage.getModuleSignature({input: fileC, name: 'lotsOfArgs'}), 'lotsOfArgs(args...);');
});
function run (pkg) {
var filepath = tempWrite.sync(JSON.stringify(pkg), 'package.json')
return mosInit({
cwd: path.dirname(filepath),
skipInstall: true,
}).then(function () { return JSON.parse(fs.readFileSync(filepath, 'utf8')) })
}
(async () => {
if (input) {
await open(input, cli.flags);
} else {
const stdin = await getStdin.buffer();
const type = fileType(stdin);
const extension = cli.flags.extension || (type && type.ext) || 'txt';
await open(tempWrite.sync(stdin, `open.${extension}`), cli.flags);
}
})();