Пример #1
0
async function main_() {
    process.exitCode = 0;

    process.on("unhandledRejection", function (reason /*, promise */) {
        console.log("Quitting on a rejected promise...");
        throw reason;
    });

    Promise.config({ warnings: true });

    const commandArgv = parseArgv();
    if (!commandArgv)
        return; // --help and such

    assert(commandArgv.length >= 2); // interpreter test-script.js ...
    const testScriptLocationFromUserPov = commandArgv[1];
    const testScriptLocationAbsolute =
        testScriptLocationFromUserPov.indexOf("file:") === 0 ?
        testScriptLocationFromUserPov : // leave file:... URLs alone
        `file://${path.resolve(testScriptLocationFromUserPov)}`;

    // import before Config.Finalize() because commands usually add options
    const CommandModule = await import(testScriptLocationAbsolute);

    if (!Config.Finalize(commandArgv))
        return;

    const test = new CommandModule.default();
    await RunTest(test);
}
function polyfillBluebird() {
  var local = null
  var Promise = require('bluebird')

  // configuration
  Promise.config({
    longStrackTraces: true,
    warnings: true
  })

  if (typeof global !== 'undefined') {
    local = global
  } else if (typeof self !== 'undefined') {
    local = self
  } else {
    try {
      local = Function('return this')()
    } catch (e) {
      throw new Error(
        'Bluebird polyfill failed because global object' +
        ' is unavailable in this environment'
      )
    }
  }

  local.Promise = Promise
}
Пример #3
0
  function TelegramBotPolling(token) {
    var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
    var callback = arguments[2];

    _classCallCheck(this, TelegramBotPolling);

    // enable cancellation
    Promise.config({
      cancellation: true
    });

    if (typeof options === 'function') {
      callback = options; // eslint-disable-line no-param-reassign
      options = {}; // eslint-disable-line no-param-reassign
    }

    this.offset = 0;
    this.token = token;
    this.callback = callback;
    this.timeout = options.timeout || 10;
    this.interval = typeof options.interval === 'number' ? options.interval : 300;
    this.lastUpdate = 0;
    this.lastRequest = null;
    this.abort = false;
    this._polling();
  }
Пример #4
0
/**
 * Load the Bluebird promise.
 */
function loadBluebird() {
  var Promise = require('bluebird')

  // Silence all warnings
  Promise.config({
    warnings: false
  })

  return Promise
}
Пример #5
0
  constructor(token, options = {}, callback) {
    // enable cancellation
    Promise.config({
      cancellation: true,
    });

    if (typeof options === 'function') {
      callback = options; // eslint-disable-line no-param-reassign
      options = {}; // eslint-disable-line no-param-reassign
    }

    this.offset = 0;
    this.token = token;
    this.callback = callback;
    this.timeout = options.timeout || 10;
    this.interval = (typeof options.interval === 'number') ? options.interval : 300;
    this.lastUpdate = 0;
    this.lastRequest = null;
    this.abort = false;
    this._polling();
  }
Пример #6
0
(function (global) {
    // import Core vendors
    require('console-polyfill');
    console.timeStamp('Bootstrap started');
    const Webiny = require('webiny').default;
    const jquery = require('jquery');
    const Promise = require('bluebird');

    global.Promise = Promise;
    global.$ = global.jQuery = jquery;
    Promise.config({
        cancellation: true,
        warnings: {
            wForgottenReturn: false
        }
    });

    global['webinyOnRender'] = (callback) => {
        Webiny.onRenderCallbacks.push(callback);
    };

    global['webinyFirstRenderDone'] = () => {
        return Webiny.firstRenderDone;
    };


    require('bootstrap-sass');

    if (DEVELOPMENT) {
        global['$Webiny'] = Webiny;
    }

    // Check if `Webiny` config exists in the global
    if (!global.webinyConfig) {
        console.error('You must define a "webinyConfig" to bootstrap your app!');
    } else {
        Webiny.run(global.webinyConfig);
    }
})(window);
Пример #7
0
 */
var ping = require('net-ping');
var chalk = require('chalk');
var mongoose = require('mongoose');
var Device = mongoose.model('Device');
var session = ping.createSession();
var interval = 1000;
var mqttSrv;
var validTargets = [];
var _ = require('lodash');
var Promise = require('bluebird');
var config = require('../../config/config');

Promise.config({
	// Enables all warnings except forgotten return statements.
	warnings: {
		wForgottenReturn: false
	}
});

module.exports = function(srv, mqttClient) {
	mqttSrv = srv;
	mqttClient.on('message', function(/* topic, buffer, data */) {
		targetSync();
	});

	targetSync();
};

function targetSync() {
	Device.find().exec(function(err, devices) {
		if (err) {
Пример #8
0
import "babel-polyfill"
import Promise from "bluebird"
Promise.config({
  longStackTraces: false
})
global.Promise = Promise
// require('source-map-support').install()
// global.onunhandledrejection = function(reason, promise) {
//       window.onerror(reason.message, "", "", "", reason);
// };

import React from "react"
import ReactDOM from "react-dom"
import App from "./flux/components/app.jsx"
import init from "./init.js"
init()

ReactDOM.render(
  <App />,
  document.querySelector("#jinro")
)

Пример #9
0
'use strict';

require('../lib/util/externals').use({
  Events: require('backbone-events-standalone'),
  extend: require('lodash/object/extend')
});

var Promise = require('bluebird');
Promise.config({
  warnings: true,
  longStackTraces: true,
  cancellation: true
});

var BayeuxWithProxyServer = require('./helpers/bayeux-with-proxy-server');

describe('node-test-suite', function() {

  before(function(done) {
    var self = this;
    this.server = new BayeuxWithProxyServer('localhost');

    this.serverControl = this.server;

    this.server.start(function(err, urls) {
      if (err) return done(err);
      self.urls = urls;
      done();
    });
  });
Пример #10
0
'use strict';

var tls = require('tls');

var assert = require('assertive');
var Bluebird = require('bluebird');

// This is important because PhantomJS has a non-writeable
// error.stack property and the resulting warnings make the tests fail...
Bluebird.config({ warnings: false });

var fetch = require('../').fetch;

var options = require('./mock-service');

describe('fetch: https', function() {
  it('can load from valid https remote', function() {
    // This is a remote call which isn't great but it means we get a valid
    // https certificate without having to pull any tricks.
    this.timeout(2000);
    return fetch('https://api.reddit.com/user/ageitgey/about.json').json();
  });

  it('fails with self-signed https', function() {
    return assert.rejects(fetch(options.baseUrlTls)).then(function(error) {
      // In browsers we don't get any nice, reliable errors (yet?)
      if (typeof document === 'undefined') {
        if (error.code) {
          // more recent node versions (e.g. 4+)
          assert.match(/SELF_SIGNED/, error.code);
        } else {
    // @deprecated
    run(conf) {
        return this.start(conf)
        .tap(() => {
            // Delay the log call until the logger is actually set up.
            if (this._impl._logger) {
                this._impl._logger.log('warn/service-runner',
                    'ServiceRunner.run() is deprecated, and will be removed in v3.x.');
            }
        });
    }

    static getLogger(loggerConf) { return new Logger(loggerConf); }
    static getMetrics(metricsConf, logger) { return makeStatsD(metricsConf, logger); }
}

module.exports = ServiceRunner;

if (module.parent === null) {
    // Cancellable promises have to enabled before we instantiate any promises. Because
    // ServiceRunner heavily relies on promises this is the best place to leave the config
    // like that.
    if (process.env.APP_ENABLE_CANCELLABLE_PROMISES) {
        P.config({
            cancellation: true
        });
    }
    // Run as a script: Start up
    new ServiceRunner().start();
}
Пример #12
0
'use strict';

var util = require('util'),
    path = require('path'),
    fs = require('fs'),
    zlib = require('zlib'),
    EventEmitter = require('events').EventEmitter;

var Promise = require('bluebird'),
    _ = require('lodash'),
    rp = require('request-promise'),
    request = require('request'),
    cheerio = require('cheerio');

// Enable cancellation.
Promise.config({ cancellation: true });

/**
 * constructor of Crawler
 */
function Crawler(opts) {
    this._init(opts);
}

// inherits from EventEmitter
util.inherits(Crawler, EventEmitter);

/**
 * initialize Crawler
 */
Crawler.prototype._init = function _init(opts) {
Пример #13
0
'use strict';

var Q = require('q');
Q.longStackSupport = true;
global.InternalPromise = Q;
module.exports.q = require('./produce-long-stack-traces');

var longStackTracePath = require.resolve('./produce-long-stack-traces');
var internalThen = require.resolve('./internal-then');
delete require.cache[longStackTracePath];
delete require.cache[internalThen];

var bluebird = require('bluebird');
bluebird.config({longStackTraces: true});
global.InternalPromise = bluebird;
module.exports.bluebird = require('./produce-long-stack-traces');
Пример #14
0
import superagent from 'superagent'
import superagentPromise from 'superagent-promise'
import Promise from 'bluebird'
import serializer from 'superagent-serializer'

Promise.config({
  warnings: {
    wForgottenReturn: false
  }
})

serializer(superagent, 'camel')

export default superagentPromise(superagent, Promise)
Пример #15
0
var _ = require('lodash');
var uuid = require('node-uuid');
var utils = require('./utils');

Promise.promisifyAll(redis.RedisClient.prototype);
Promise.promisifyAll(redis.Multi.prototype);

/*
console.error = function(){
};
*/

Promise.config({
  // Enable warnings.
  // warnings: true,
  // Enable long stack traces.
  longStackTraces: process.NODE_ENV !== 'production',
  // Enable cancellation.
  cancellation: true
});

describe('Queue', function () {
  var sandbox = sinon.sandbox.create();

  beforeEach(function(){
    var client = redis.createClient();
    return client.flushdbAsync();
  });

  afterEach(function(){
    sandbox.restore();
  });
Пример #16
0
'use strict';
const Promise = require('bluebird');
const Database = require('./data');

Promise.config({
    // Enable warnings
    warnings: true,
    // Enable long stack traces
    longStackTraces: true,
    // Enable cancellation
    cancellation: true,
    // Enable monitoring
    monitoring: true
});

const knexOptions = {
    client: 'sqlite3',
    // debug: true,
    connection: {
        filename: "./test.sqlite"
    },
    useNullAsDefault: true
};

describe('Class: Database', () => {
    let fixture;
    describe('constructor()', () => {
        it('when defined callback, should call after create table finished', () => {
            let callback = jasmine.createSpy('callback');
            let resolved = Promise.resolve({});
            spyOn(resolved, 'then');
Пример #17
0
Файл: main.js Проект: Bigsby/PoC
import '@babel/polyfill';
import environment from './environment';
import {PLATFORM} from 'aurelia-pal';
import * as Bluebird from 'bluebird';

// remove out if you don't want a Promise polyfill (remove also from webpack.config.js)
Bluebird.config({ warnings: { wForgottenReturn: false } });

export function configure(aurelia) {
  aurelia.use
    .standardConfiguration()
    .feature(PLATFORM.moduleName('resources/index'));

  // Uncomment the line below to enable animation.
  // aurelia.use.plugin(PLATFORM.moduleName('aurelia-animator-css'));
  // if the css animator is enabled, add swap-order="after" to all router-view elements

  // Anyone wanting to use HTMLImports to load views, will need to install the following plugin.
  // aurelia.use.plugin(PLATFORM.moduleName('aurelia-html-import-template-loader'));

  aurelia.use.developmentLogging(environment.debug ? 'debug' : 'warn');

  if (environment.testing) {
    aurelia.use.plugin(PLATFORM.moduleName('aurelia-testing'));
  }

  return aurelia.start().then(() => aurelia.setRoot(PLATFORM.moduleName('app')));
}
Пример #18
0
"use strict";

var Testing = require("../lib/testing/Testing");
var Deprecated = require("../lib/util/Deprecated");
var Promise = require("bluebird");

Promise.config({
    warnings: false
});

beforeEach(function() {
    Testing.setup();
    spyOn(Deprecated, "message");
});

// ----------------------------------------------------------------------------
// Copyright (C) 2018 Bloomberg Finance L.P.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// ----------------------------- END-OF-FILE ----------------------------------
Пример #19
0
'use strict';

const Bluebird = require('bluebird');

/** {@link http://bluebirdjs.com/docs/api/promise.config.html} */
Bluebird.config({
  cancellation: true,
});

module.exports = Bluebird;
Пример #20
0
import environment from './environment';
import {PLATFORM} from 'aurelia-pal';
import 'babel-polyfill';
import * as Bluebird from 'bluebird';

//initializing fetch polyfill
//import 'fetch';

// remove out if you don't want a Promise polyfill (remove also from webpack.config.js)
//Bluebird.config({ warnings: { wForgottenReturn: false } });
Bluebird.config( { warnings: { wForgottenReturn: false }, longStackTraces: false } );

export function configure(aurelia) {
  aurelia.use
    .standardConfiguration()
    //.plugin(PLATFORM.moduleName('aurelia-dialog'))
    //.plugin(PLATFORM.moduleName('aurelia-formio'))
    //.plugin(PLATFORM.moduleName('aurelia-ace-editor'))
    .feature(PLATFORM.moduleName('resources/index'));

  if (environment.debug) {
    aurelia.use.developmentLogging();
  }

  if (environment.testing) {
    aurelia.use.plugin(PLATFORM.moduleName('aurelia-testing'));
  }

  aurelia.start().then(() => aurelia.setRoot(PLATFORM.moduleName('virtualfoldersetting/app')));
}
Пример #21
0
/* jshint browser:true */
'use strict';

require('../lib/util/externals').use({
  Events: require('backbone-events-standalone'),
  extend: require('lodash/object/extend')
});

var Promise = require('bluebird');
Promise.config({
  warnings: true,
  longStackTraces: !!window.localStorage.BLUEBIRD_LONG_STACK_TRACES,
  cancellation: true
});

var RemoteServerControl = require('./helpers/remote-server-control');

describe('browser integration tests', function() {
  this.timeout(30000);

  before(function() {
    this.serverControl = new RemoteServerControl();
    return this.serverControl.setup()
      .bind(this)
      .then(function(urls) {
        this.urls = urls;
      });
  });

  after(function() {
    return this.serverControl.teardown();
Пример #22
0
const express = require('express');
const http = require('http');
const path = require('path');
const chalk = require('chalk');
const init = require('./server/init');
const Promise = require("bluebird");
// Configure
Promise.config({
	longStackTraces: true,
	warnings: true
});

const PORT = 8081;

var app = express();

app.use(express.static('src', { maxAge: 86400000 }));

var server = http
	.createServer(app)
	.listen(PORT);


init(server);


console.log(chalk.green([
	'Server Started On:',
	'http://localhost:' + PORT + '/',
	''
].join('\n')));
Пример #23
0
/**
 * This is the entrypoint for the Webpack app.
 * Require any polyfills and global runtimes here.
 */

// we want font-awesome to load as soon as possible to show the fa-spinner
import './styles/styles.css';
import 'font-awesome/css/font-awesome.css';
import 'bootstrap/dist/css/bootstrap.css';

// comment out if you don't want a Promise polyfill (remove also from config/webpack.common.js)
import * as Bluebird from 'bluebird';
Bluebird.config({
  //// Enable long stack traces
  // longStackTraces: true,
  //// Enable cancellation
  // cancellation: true,
  //// Enable monitoring
  // monitoring: true,
  // Enable warnings
  warnings: false
});

import 'aurelia-polyfills';
import {initialize} from 'aurelia-pal-browser';

// PAL has to be initialized in the first chunk, before any of the Aurelia files are loaded
// the reason is that Webpack resolves all the imports immediately, as the chunks are loaded
// Some modules use {DOM} from 'aurelia-pal' and expect it to already be initialized.
initialize();
Пример #24
0
import fetch from 'node-fetch';
import invariant from 'invariant';
import logger from 'morgan';
import mongoStore from 'connect-mongo';
import passport from 'passport';
import session from 'express-session';

import path from 'path';

import Repo from './models/repo';
import Tag from './models/tag';
import User from './models/user';
import graphqlHTTP from './graphql';

Promise.config({
  // Enable cancellation
  cancellation: true,
});

dotenv.load({ path: '.env.dev' });

require('./configPassport');

import { SUCCESS, BAD_REQUEST, SERVER_ERROR } from './errorCodes';

// eslint-disable-next-line
Promise.promisifyAll(Mongoose);

// global stuffs
global.Promise = Promise;
global._ = _;
Пример #25
0
"use strict";

global._ = require('./modules/utils/underscore');

const Q = require('bluebird');
Q.config({
    cancellation: true,
});

const fs = require('fs');
const electron = require('electron');
const app = electron.app;
const dialog = electron.dialog;
const timesync = require("os-timesync");
const syncMinimongo = require('./modules/syncMinimongo.js');
const ipc = electron.ipcMain;
const packageJson = require('./package.json');
const i18n = require('./modules/i18n.js');
const logger = require('./modules/utils/logger');
const Sockets = require('./modules/sockets');
const Windows = require('./modules/windows');
const ClientBinaryManager = require('./modules/clientBinaryManager');

const Settings = require('./modules/settings');
Settings.init();


if (Settings.cli.version) {
    console.log(Settings.appVersion);

    process.exit(0);
Пример #26
0
var asar = require('asar')
var child = require('child_process')
var fs = require('fs-extra')
const promisifiedFs = require('fs-extra-p')
var minimist = require('minimist')
var os = require('os')
var path = require('path')
var series = require('run-series')
const sanitize = require('sanitize-filename')
const Promise = require('bluebird')

var archs = ['ia32', 'x64']
var platforms = ['darwin', 'linux', 'mas', 'win32']

Promise.config({
  longStackTraces: true
})

function parseCLIArgs (argv) {
  var args = minimist(argv, {
    boolean: [
      'prune',
      'asar',
      'all',
      'overwrite',
      'download.strictSSL'
    ],
    alias: {
      'download.strictSSL': 'strict-ssl'
    },
    default: {
Пример #27
0
		}

		return str;
	},
	configurable: true
});

process.on('unhandledRejection', (reason, promise) => {
	console.trace("Unhandled rejection", reason);
});


let bluebirdConfig = {
	longStackTraces: true
};
Promise.config(bluebirdConfig)
Sequelize.Promise.config(bluebirdConfig);


const database = new Database(config.db);

utils.promiseAuto({
	databaseConnect: database.connect(),

	server: (databaseConnect) => {
		return webserver.init(database, config.port, config.host);
	},

	socket: (server) => {
		return new Socket(server, database);
	}