How to use the rsvp.denodeify function in rsvp

To help you get started, we’ve selected a few rsvp 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 ember-cli / ember-cli / lib / utilities / clean-remove.js View on Github external
'use strict';

const path = require('path');
const fs = require('fs-extra');
const RSVP = require('rsvp');
const walkUp = require('./walk-up-path');

const Promise = RSVP.Promise;
const stat = RSVP.denodeify(fs.stat);
const remove = RSVP.denodeify(fs.remove);
const readdir = RSVP.denodeify(fs.readdir);

function cleanRemove(fileInfo) {
  // see if file exists to avoid wasting time
  return stat(fileInfo.outputPath)
    .then(() => remove(fileInfo.outputPath))
    .then(() => {
      let paths = walkUp(fileInfo.displayPath).map(thePath => path.join(fileInfo.outputBasePath, thePath));

      return paths.reduce(
        (chainedPromise, thePath) =>
          chainedPromise.then(wasShortCircuited => {
            if (wasShortCircuited) {
              // optimization that says since my child dir wasn't empty,
              // I can't be empty, so keep skipping
              return true;
github ember-cli / ember-cli / lib / cli / load-tasks.js View on Github external
'use strict';

// Loads tasks and assembles them into a hash.

var RSVP = require('rsvp');
var glob = RSVP.denodeify(require('glob'));
var path = require('path');
var camelize = require('../utilities/string').camelize;

module.exports = loadTasks;
function loadTasks() {
  return glob(__dirname + '/../tasks/*.js').then(buildHash);
}

function buildHash(files) {
  return files.reduce(function(tasks, file) {
    var task = loadTaskFromFile(file);
    tasks[task.key] = task;
    return tasks;
  }, {});
}
github ember-cli / ember-cli / lib / cli / find-project.js View on Github external
'use strict';

// Searches from the cwd upwards for a package.json. If that package.json
// includes ember-cli as devDependency then it returns
// { directory: String, packageJSON: Object } else it returns null.

var RSVP   = require('rsvp');
var findup = RSVP.denodeify(require('findup'));
var readFile = RSVP.denodeify(require('fs').readFile);

module.exports = findProject;
function findProject() {
  return findup(process.cwd(), 'package.json')
    .then(function(dir) {
      return readFile(dir + '/package.json', 'utf8')
        .then(function(rawPackageJSON) {
          var packageJSON = JSON.parse(rawPackageJSON);

          if (isEmberCLIProject(packageJSON)) {
            return {
              directory: dir,
              packageJSON: packageJSON
            };
          } else {
            return null;
github ember-cli / ember-cli / lib / cli / load-commands.js View on Github external
'use strict';

// Loads commands and assembles them into a hash.

var RSVP = require('rsvp');
var glob = RSVP.denodeify(require('glob'));
var path = require('path');
var camelize = require('../utilities/string').camelize;

module.exports = loadCommands;
function loadCommands() {
  return glob(__dirname + '/../commands/*.js').then(buildHash);
}

function buildHash(files) {
  return files.reduce(function(commands, file) {
    var command = loadCommandFromFile(file);
    commands[command.key] = command;
    return commands;
  }, {});
}
github tomdale / lambda-packager / lib / server / build-dependencies.js View on Github external
var fs           = require('fs');
var childProcess = require('child_process');
var path         = require('path');
var AWS          = require('aws-sdk');
var RSVP         = require('rsvp');
var archiver     = require('archiver');
var chalk        = require('chalk');
var util         = require('util');

var mkdir        = RSVP.denodeify(fs.mkdir);
var writeFile    = RSVP.denodeify(fs.writeFile);
var exec         = RSVP.denodeify(childProcess.exec);

var root         = __dirname;

// This is the main entry point that Lambda invokes to handle the
// request to build the provided packages.
//
// The workflow is:
//
// 1. Create /tmp//
// 2. Copy the provided package.json to /tmp//package.json
// 3. Run npm install in that directory
// 4. Zip the resulting node_modules directory
// 5. Upload the zip file to //node_modules.zip

module.exports = function buildDependencies(packages, bucket, requestID) {
  var tmpDir = path.join("/tmp/", requestID);
github ember-animation / ember-animated / packaging / release.js View on Github external
#!/usr/bin/env node

/* jshint node: true */

var fs = require('fs');
var path = require('path');
var RSVP = require('rsvp');
var run = require('./promise_spawn');
var stat = RSVP.denodeify(fs.stat);
var readdir = RSVP.denodeify(fs.readdir);
var copy = RSVP.denodeify(require('ncp').ncp);
var program = require('commander');
var gitRepoInfo = require('git-repo-info');

function version() {
  return require('../package.json').version;
}

function repo() {
  return require('../package.json').repository;
}

function pushURL(github) {
  return repo().replace('github', github.auth.token + '@github');
}
github ember-fastboot / ember-cli-fastboot / lib / commands / fastboot.js View on Github external
'use strict';

const RSVP = require('rsvp');
const getPort = RSVP.denodeify(require('portfinder').getPort);
const ServerTask = require('../tasks/fastboot-server');
const SilentError = require('silent-error');
const VersionChecker = require('ember-cli-version-checker');

const blockForever = () => (new RSVP.Promise(() => {}));

module.exports = function(addon) {
  return {
    name: 'fastboot',
    description: 'Builds and serves your FastBoot app, rebuilding on file changes.',

    availableOptions: [
      { name: 'build', type: Boolean, default: true },
      { name: 'watch', type: Boolean, default: true, aliases: ['w'] },
      { name: 'environment', type: String, default: 'development', aliases: ['e',{'dev' : 'development'}, {'prod' : 'production'}] },
      { name: 'serve-assets', type: Boolean, default: false },
github stefanpenner / async-disk-cache / index.js View on Github external
'use strict';

const path = require('path');
const RSVP = require('rsvp');
const fs = require('fs');
const readFile = RSVP.denodeify(fs.readFile);
const writeFile = RSVP.denodeify(fs.writeFile);
const renameFile = RSVP.denodeify(fs.rename);
const chmod = RSVP.denodeify(fs.chmod);
const mkdirp = RSVP.denodeify(require('mkdirp'));
const rimraf = RSVP.denodeify(require('rimraf'));
const unlink = RSVP.denodeify(fs.unlink);
const os = require('os');
const debug = require('debug')('async-disk-cache');
const zlib = require('zlib');
const heimdall = require('heimdalljs');
const crypto = require('crypto');

const CacheEntry = require('./lib/cache-entry');
const Metric = require('./lib/metric');

if (!heimdall.hasMonitor('async-disk-cache')) {
  heimdall.registerMonitor('async-disk-cache', function AsyncDiskCacheSchema() {});
}
github petkaantonov / bluebird / benchmark / lib / fakesP.js View on Github external
function dummyP(n) {
    return lifter(f.dummy(n));
}
github stefanpenner / async-disk-cache / index.js View on Github external
}

const COMPRESSIONS = {
  deflate: {
    in: RSVP.denodeify(zlib.deflate),
    out: RSVP.denodeify(zlib.inflate)
  },

  deflateRaw: {
    in: RSVP.denodeify(zlib.deflateRaw),
    out: RSVP.denodeify(zlib.inflateRaw)
  },

  gzip: {
    in: RSVP.denodeify(zlib.gzip),
    out: RSVP.denodeify(zlib.gunzip)
  },
};
/*
 *
 * @class Cache
 * @param {String} key the global key that represents this cache in its final location
 * @param {String} options optional string path to the location for the
 *                          cache. If omitted the system tmpdir is used
 */
class Cache {
  constructor(key, _) {
    const options = _ || {};
    this.tmpdir = options.location|| tmpdir;
    this.compression = options.compression || false;
    this.supportBuffer = options.supportBuffer || false;
    this.key = key || 'default-disk-cache';