Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function start() {
await getStream(await docker.pull(IMAGE));
container = await docker.createContainer({
Tty: true,
Image: IMAGE,
PortBindings: {[`${COUCHDB_PORT}/tcp`]: [{HostPort: `${SERVER_PORT}`}]},
Env: [`COUCHDB_USER=${COUCHDB_USER}`, `COUCHDB_PASSWORD=${COUCHDB_PASSWORD}`],
});
await container.start();
await delay(4000);
try {
// Wait for the registry to be ready
await pRetry(() => got(`http://${SERVER_HOST}:${SERVER_PORT}/registry/_design/app`, {cache: false}), {
retries: 7,
minTimeout: 1000,
factor: 2,
});
} catch (_) {
throw new Error(`Couldn't start npm-docker-couchdb after 2 min`);
}
// Create user
await got(`http://${SERVER_HOST}:${SERVER_PORT}/_users/org.couchdb.user:${NPM_USERNAME}`, {
json: true,
auth: `${COUCHDB_USER}:${COUCHDB_PASSWORD}`,
const delay =
methodOptions &&
typeof methodOptions === 'object' &&
typeof methodOptions.delay === 'number'
? methodOptions.delay
: options.delay;
if (methodOptions) {
args[len - 1] = omit(methodOptions, ['delay']);
}
if (this.typingOn) {
await this.typingOn();
}
await sleep(delay);
return _method.call(context, ...args);
};
/* eslint-enable func-names */
async componentDidMount() {
// UI Boot
await delay(150)
const { isFirstVisit, ...actions } = this.props
if (isFirstVisit) {
// Start omotenashi
// Remove first visit flag
await actions.setConfigValue({ key: "isFirstVisit", value: false })
// Open scratch.md as user first view
actions.loadFile({ filepath: "/playground/scratch.md" })
// TODO: Reload git on init. Sometimes initialze on git is failing
await delay(300)
actions.initializeGitStatus("/playground")
}
// TODO: dirty hack to focus
// Focus first element
await delay(150)
const target = (document as any).querySelector("textarea")
target && target.focus()
}
})
app.on('ready', async () => {
// transparency workaround https://github.com/electron/electron/issues/2170
await delay(10)
mb = menubar({
alwaysOnTop: process.env.NODE_ENV === 'development',
icon: path.join(app.getAppPath(), '/static/tray.png'),
width: 500,
minWidth: 500,
maxWidth: 500,
minHeight: 530,
hasShadow: false,
preloadWindow: true,
resizable: true,
transparent: true,
frame: false,
toolbar: false
})
async function dev() {
let proc;
const wrapper = () => {
if (proc) {
proc.kill();
}
};
process.on('SIGINT', wrapper);
process.on('SIGTERM', wrapper);
process.on('exit', wrapper);
proc = serve(server, false);
await delay(300);
// const app = module.exports.__REACT_SSR_EXPRESS__;
// app.listen(8888, async () => {
// const url = (route) => `http://localhost:8888${route}`;
// spinner.create(`Building '/'`);
// await got(url('/'));
// spinner.create(`Building '/' (test 2)`);
// await got(url('/'));
// spinner.create(`Building '/' (test 3)`);
// await got(url('/'));
// spinner.clear('Success!');
test('cache', async t => {
const alfy = createAlfy();
t.deepEqual(await alfy.fetch(`${URL}/cache`, {maxAge: 5000}), {hello: 'world'});
t.deepEqual(await alfy.fetch(`${URL}/cache`, {maxAge: 5000}), {hello: 'world'});
await delay(5000);
t.deepEqual(await alfy.fetch(`${URL}/cache`, {maxAge: 5000}), {hello: 'world!'});
});
async (t, { page, utils }) => {
const name = 'x-example';
await utils.waitForUpgrade(name);
await page.evaluate(name => {
const node = document.createElement(name);
node.style.display = 'block';
node.style.width = '200px';
node.style.height = '300px';
node.style.transform = 'translate(0, -250px)';
document.body.append(node);
return node.idle();
}, name);
await delay(100);
t.snapshot(await utils.innerHTML(name));
await page.evaluate(name => {
const node = document.querySelector(name);
node.style.transform = 'translate(0, -100px)';
}, name);
await delay(100);
t.snapshot(await utils.innerHTML(name));
await page.evaluate(name => {
const node = document.querySelector(name);
node.style.transform = 'translate(0, 0)';
}, name);
await delay(100);
t.snapshot(await utils.innerHTML(name));
}
function taskRunner(){
self.lock = true;
delay(self.options.delay).then(() => {
self.tasks[self.taskList[0].task](self.taskList[0].param).then(content => {
let _content = content || {};
self.taskList.splice(0, 1);
self.lock = false;
if (self.options.statusBar && statusBar) {
statusBar.tick(_content);
}
if (_.size(self.taskList) > 0){
return taskRunner();
}else{
resolve(self.taskList)
return;
}
})
async maybeSkip (adapter, current) {
const history = await adapter.getDJHistory().getRecent(this.options.limit)
const dj = await adapter.getDJBooth().getDJ()
if (this.exemptions.check(dj)) {
return
}
const lastPlay = history.find((entry) => this.isHistoryMatch(entry, current))
if (lastPlay) {
const duration = moment.duration(Date.now() - lastPlay.playedAt, 'milliseconds')
adapter.send(
`@${dj.username} This song was played ${duration.humanize()} ago` +
(lastPlay.user ? ` by ${lastPlay.user.username}` : '') +
'.'
)
await delay(500)
await lockskip(adapter, { position: this.options.position })
}
}
}
private async runReadyPhase() {
log(`Entering phase ${GamePhase[GamePhase.READY]}`);
this.phase = GamePhase.READY;
this.players.forEach(p => p.enterReadyPhase(this.turnSimulator, this.opponentProvider));
await delay(this.phaseLengths[GamePhase.READY] * 1000);
}