How to use the q.denodeify function in q

To help you get started, we’ve selected a few q examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github lukasmartinelli / detectivegit / analyzer.js View on Github external
'use strict';
var PMD_BINARY = process.env.PMD_BINARY || 'pmd';
var path = require('path');
var Q = require('q');
var exec = Q.denodeify(require('child_process').exec);
var execFile = Q.denodeify(require('child_process').execFile);
var execFileOldschool = require('child_process').execFile;
var rmdir = Q.denodeify(require('rimraf'));
var temp = require('temp');
var mkdtemp = Q.denodeify(temp.mkdir);

// Automatically track and cleanup files at exit
temp.track();

function clone(dirPath, repo) {
    var cloneUrl = 'https://nouser:nopass@github.com/' + repo + '.git';
    console.log('Cloning ' + cloneUrl + ' to ' + path.resolve(dirPath));
    return execFile('git', ['clone', '-q', cloneUrl], { cwd: dirPath });
}

function findDefaultBranch(repoPath) {
    console.log('Looking for default branch' + repoPath);
    var options = { cwd: repoPath };
    var cmd = 'git rev-parse --abbrev-ref HEAD';
    return exec(cmd, options).then(function(stdout) {
        return stdout[0].trim();
github bower / decompress-zip / lib / extractors.js View on Github external
var stream = require('stream');
if (!stream.Readable) {
    var stream = require('readable-stream');
}
var fs = require('graceful-fs');
var Q = require('q');
var path = require('path');
var zlib = require('zlib');
var touch = Q.denodeify(require('touch'));
var mkpath = Q.denodeify(require('mkpath'));
var writeFile = Q.denodeify(fs.writeFile);
var inflateRaw = Q.denodeify(zlib.inflateRaw);
var symlink = Q.denodeify(fs.symlink);
var stat = Q.denodeify(fs.stat);
var cache = {};

// Use a cache of promises for building the directory tree. This allows us to
// correctly queue up file extractions for after their path has been created,
// avoid trying to create the path twice and still be async.
var mkdir = function (dir, mode) {
    dir = path.normalize(path.resolve(process.cwd(), dir) + path.sep);
    if (mode === undefined) {
        mode = parseInt('777', 8) & (~process.umask());
    }

    if (!cache[dir]) {
        var parent;

        if (fs.existsSync(dir)) {
            parent = new Q();
github appium-boneyard / appium-ci / jenkins-gulper / lib / utils.js View on Github external
'use strict';

const Q = require('q');
const exec = Q.denodeify(require('child_process').exec);
const spawn = require('child_process').spawn;
const fs = require('fs');
const uncolor = require('uncolor');
const _ = require('underscore');
const path = require('path');

function encode (s) {
  return s.replace(/\s/g, '%20');
}

function smartSpawn (bin, args, opts) {
  opts = opts || {};

  // custom opts
  const logFile = opts.logFile;
  delete opts.logFile;
github camomile-project / camomile-server / models / MetaData.js View on Github external
metadataSchema.statics.removeFile = function(object, upload_dir) {
    var filePath = this.generateFilePath(object.token, object.filename, upload_dir);
    var pAccess = Q.denodeify(fs.access);
    var pUnlink = Q.denodeify(fs.unlink);

    console.log('Remove file ' + filePath.fullPath);

    return pAccess(filePath.fullPath, fs.F_OK | fs.W_OK)
        .then(function() {
            return pUnlink(filePath.fullPath)
        });
};
github Backbase / bb-cli / commands / config.js View on Github external
var Command = require('ronin').Command;
var Q = require('q');
var fs = require('fs-extra');
var readFile = Q.denodeify(fs.readFile);
var outputFile = Q.denodeify(fs.outputFile);
var ask = Q.denodeify(require('asking').ask);
var HOME = process.env[(process.platform === 'win32') ? 'USERPROFILE' : 'HOME'];
var seq = [searchConfig, askName, askEmail, writeConfig];

module.exports = Command.extend({
    desc: 'Prepare CLI configuration.',

    run: function () {
        seq.reduce(Q.when, Q({}))
        .fail(function(p) {
            console.log('fail', p);
        })
        .done();
    }
});
github conventional-changelog / conventional-changelog / presets / jquery.js View on Github external
'use strict';
var Q = require('q');
var readFile = Q.denodeify(require('fs').readFile);
var resolve = require('path').resolve;
var semver = require('semver');

function presetOpts(cb) {
  var parserOpts = {
    headerPattern: /^(\w*)\: (.*)$/,
    headerCorrespondence: [
      'component',
      'shortDesc'
    ]
  };

  var writerOpts = {
    transform: function(commit) {
      var componentLength;
github uditalias / swamp / lib / objects / swampService.js View on Github external
_killProcess: function (signal) {

        if (this.process) {

            Q.denodeify(psTree.bind(psTree))(this.pid)
                .then(this._onProcessTree.bind(this))

            this.process.kill(signal || this._stopSignal);
        }

    },
github pszuster / 3ScaleTD / 3scale-Swagger-Import / lib / activedocs.js View on Github external
var nconf = require("nconf");
var cli = require("./3scale-cli");
var config = require("./config");
var slug = require("slug");
var Q = require("q");
var request = Q.denodeify(require("request"));

var SwaggerParser = require('swagger-parser');

exports.listActiveDocs = function(){
  var url = config.API+"/active_docs.json";

  var options ={
    method: 'GET',
    url: url,
    form:{
      "access_token": config.access_token
    },
	  rejectUnauthorized: false
  };

  var response = request(options);
github Backbase / bb-cli / commands / ln.js View on Github external
var Command = require('ronin').Command;
var Q = require('q');
var fs = require('fs-extra');
var path = require('path');
var readFile = Q.denodeify(fs.readFile);
var readDir = Q.denodeify(fs.readdir);
var remove = Q.denodeify(fs.remove);
var lstat = Q.denodeify(fs.lstat);
var utils = require('../lib/util');
var createLink = require('../lib/createLink');
var chalk = require('chalk');

module.exports = Command.extend({
    help: function () {
        var title = chalk.bold;
        var d = chalk.gray;
        var r = '\n  ' + title('Usage') + ': bb ' + this.name + ' [OPTIONS]';
        r += '\n\n\t Symlinks source directory to defined target.';
        r += '\n\t Note: if package name starts with `widget-` it will be stripped out.';
        r += '\n\n  ' + title('Examples') + ':';
        r += '\n\n\t Minimal set-up `bb ln --target /some/path` - will symlink current dir to target. ';
        r += '\n\n\t As an alternative to `--target`, use other customized target flags: ';
        r += '\n\n\t - If --lp-trunk path is set, target will be:';
github monaca / monaca-lib / src / monaca.js View on Github external
var createTmpFile = function() {
      return Q.denodeify(tmp.file)()
        .then(
          function() {
            return arguments[0][0];
          }
        );
    };