How to use kew - 10 common examples

To help you get started, we’ve selected a few kew 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 Medium / zcache / test / test_CachePair.js View on Github external
.then(function (data) {
      test.equal('value', data, 'The get() should return the right value from the secondary instance')
      test.equals(1, cache2.getRequestCounts()['get'], 'The secondary cache should get one get()')

      // the following is a fragile test... any better ideas?
      return Q.delay(20)
    })
    .then(function () {
github aerisweather / aerisjs / node_modules / grunt-jasmine-legacy / node_modules / phantomjs / install.js View on Github external
var pkgPath = path.join(libPath, 'phantom')
var phantomPath = null
var tmpPath = null

// If the user manually installed PhantomJS, we want
// to use the existing version.
//
// Do not re-use a manually-installed PhantomJS with
// a different version.
//
// Do not re-use an npm-installed PhantomJS, because
// that can lead to weird circular dependencies between
// local versions and global versions.
// https://github.com/Obvious/phantomjs/issues/85
// https://github.com/Medium/phantomjs/pull/184
var whichDeferred = kew.defer()
which('phantomjs', whichDeferred.makeNodeResolver())
whichDeferred.promise
  .then(function (result) {
    phantomPath = result

    // Horrible hack to avoid problems during global install. We check to see if
    // the file `which` found is our own bin script.
    if (phantomPath.indexOf(path.join('npm', 'phantomjs')) !== -1) {
      console.log('Looks like an `npm install -g` on windows; unable to check for already installed version.')
      throw new Error('Global install')
    }

    var contents = fs.readFileSync(phantomPath, 'utf8')
    if (/NPM_INSTALL_MARKER/.test(contents)) {
      console.log('Looks like an `npm install -g`; unable to check for already installed version.')
      throw new Error('Global install')
github sx1989827 / DOClever / node_modules / phantomjs-prebuilt / install.js View on Github external
function tryPhantomjsInLib() {
  return kew.fcall(function () {
    return findValidPhantomJsBinary(path.resolve(__dirname, './lib/location.js'))
  }).then(function (binaryLocation) {
    if (binaryLocation) {
      console.log('PhantomJS is previously installed at', binaryLocation)
      exit(0)
    }
  }).fail(function () {
    // silently swallow any errors
  })
}
github Medium / phantomjs / install.js View on Github external
function tryPhantomjsInLib() {
  return kew.fcall(function () {
    return findValidPhantomJsBinary(path.resolve(__dirname, './lib/location.js'))
  }).then(function (binaryLocation) {
    if (binaryLocation) {
      console.log('PhantomJS is previously installed at', binaryLocation)
      exit(0)
    }
  }).fail(function () {
    // silently swallow any errors
  })
}
github ExactTarget / fuelux / node_modules / grunt-contrib-qunit / node_modules / grunt-lib-phantomjs / node_modules / phantomjs / install.js View on Github external
function extractDownload(filePath) {
  var deferred = kew.defer()
  // extract to a unique directory in case multiple processes are
  // installing and extracting at once
  var extractedPath = filePath + '-extract-' + Date.now()
  var options = {cwd: extractedPath}

  mkdirp.sync(extractedPath, '0777')
  // Make double sure we have 0777 permissions; some operating systems
  // default umask does not allow write by default.
  fs.chmodSync(extractedPath, '0777')

  if (filePath.substr(-4) === '.zip') {
    console.log('Extracting zip contents')

    try {
      var zip = new AdmZip(filePath)
      zip.extractAllTo(extractedPath, true)
github sx1989827 / DOClever / node_modules / phantomjs-prebuilt / install.js View on Github external
return kew.nfcall(fs.remove, targetPath).then(function () {
    // Look for the extracted directory, so we can rename it.
    var files = fs.readdirSync(extractedPath)
    for (var i = 0; i < files.length; i++) {
      var file = path.join(extractedPath, files[i])
      if (fs.statSync(file).isDirectory() && file.indexOf(helper.version) != -1) {
        console.log('Copying extracted folder', file, '->', targetPath)
        return kew.nfcall(fs.move, file, targetPath)
      }
    }

    console.log('Could not find extracted file', files)
    throw new Error('Could not find extracted file')
  })
}
github volumio / Volumio2 / app / plugins / music_service / music_library / lib / utils.js View on Github external
return iterateArrayAsync(folderEntries, function(folderEntry) {
			var childLocation = path.join(location, folderEntry);

			// get stats
			return libQ.nfcall(fs.stat, childLocation).then(function(stats) {
				// 'Stats' are a little bit different from 'Dirent'
				stats.name = folderEntry;
				return stats;
			}).fail(function(err) {
				// skip errors
				console.log(err);
			});
		});
	});
github Medium / phantomjs / install.js View on Github external
function copyIntoPlace(extractedPath, targetPath) {
  console.log('Removing', targetPath)
  return kew.nfcall(fs.remove, targetPath).then(function () {
    // Look for the extracted directory, so we can rename it.
    var files = fs.readdirSync(extractedPath)
    for (var i = 0; i < files.length; i++) {
      var file = path.join(extractedPath, files[i])
      if (fs.statSync(file).isDirectory() && file.indexOf(helper.version) != -1) {
        console.log('Copying extracted folder', file, '->', targetPath)
        return kew.nfcall(fs.move, file, targetPath)
      }
    }

    console.log('Could not find extracted file', files)
    throw new Error('Could not find extracted file')
  })
}
github volumio / Volumio2 / app / metadatacache.js View on Github external
CoreMetadataCache.prototype.fetchAlbumArt = function(sMbid, sBasePath) {
	var self = this;
	var bufferImage = null;
	var sPath = '';

console.log('fetching art for ' + sMbid);
	return libQ.nfcall(libFast.bind(self.coverArtClient.release, self.coverArtClient), sMbid, {piece: 'front'})
		.then(function(out) {
			bufferImage = out.image;
			sPath = sBasePath + '/' + sMbid + out.extension;
console.log(sPath);
			return libQ.nfcall(libFileSystem.open, sPath, 'w');
		})
		.then(function(file) {
			return libQ.nfcall(libFileSystem.write, file, bufferImage, 0, 'binary');
		})
		.then(function(result) {
			console.log('file written');
			return sPath;
		})
		.fail(function(error) {
			// Have this clause to catch errors so the parent promise does not abort
			return sPath;
github Medium / zcache / lib / RedisConnection.js View on Github external
.then(function (infoCmdOutput) {
      var items = {}
      infoCmdOutput.split('\n')
        .filter(function(str) {return str.indexOf(':') > 0})
        .map(function(str) {return str.trim().split(':')})
        .map(function(item) {items[item[0]] = item[1]})
      var serverInfo = new ServerInfo()
      try {
        serverInfo.memoryBytes = parseInt(items['used_memory'], 10)
        serverInfo.memoryRssBytes = parseInt(items['used_memory_rss'], 10)
        serverInfo.evictedKeys = parseInt(items['evicted_keys'], 10)
        serverInfo.numOfConnections = parseInt(items['connected_clients'], 10)
        // The db0 key's value is something like: 'keys=12,expires=20'
        serverInfo.numOfKeys = parseInt(items['db0'].split(',')[0].split('=')[1], 10)
      } catch (e) {
        Q.reject(new Error('Malformatted output from the "INFO" command of Redis'))
      }
      return Q.resolve(serverInfo)
    })
}

kew

a lightweight promise library for node

Apache-2.0
Latest version published 9 years ago

Package Health Score

59 / 100
Full package analysis