How to use pify - 10 common examples

To help you get started, we’ve selected a few pify 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 nuxt / nuxt.js / lib / build.js View on Github external
function createRenderer (bundle, manifest) {
  // Create bundle renderer to give a fresh context for every request
  this.renderer = createBundleRenderer(bundle, Object.assign({
    clientManifest: manifest,
    runInNewContext: false,
    inject: false,
    baseDir: this.options.dir
  this.renderToString = pify(this.renderer.renderToString)
  this.renderToStream = this.renderer.renderToStream
github xojs / xo / test / lint-text.js View on Github external
import fs from 'fs';
import path from 'path';
import test from 'ava';
import pify from 'pify';
import fn from '..';


const readFile = pify(fs.readFile);
const hasRule = (results, ruleId) => results[0].messages.some(x => x.ruleId === ruleId);

test('.lintText()', t => {
	const {results} = fn.lintText('\'use strict\'\nconsole.log(\'unicorn\');\n');
	t.true(hasRule(results, 'semi'));

test('default `ignores`', t => {
	const result = fn.lintText('\'use strict\'\nconsole.log(\'unicorn\');\n', {
		filename: 'node_modules/ignored/index.js'
	});, 0);, 0);

test('`ignores` option', t => {
github electron-userland / electron-compile / test / file-change-cache.js View on Github external
import './support.js';

import FileChangeCache from '../src/file-change-cache';
import path from 'path';
import fs from 'fs';
import pify from 'pify';
const pfs = pify(fs);

describe('The file changed cache', function() {
  beforeEach(function() {
    this.fixture = new FileChangeCache(null);

  it("Correctly computes a file hash for a canned file", async function() {
    const expectedInfo = {
      hash: '4a92e95074156e8b46869519c43ddf10b59299a4',
      hasSourceMap: false,
      isInNodeModules: false,
      isMinified: false,
      isFileBinary: false

    let input = path.resolve(__dirname, '..', 'test', 'fixtures', 'valid.js');
github radiovisual / timecard / test / clockout.js View on Github external
test('prevent clockout before clockin', async t => {
	const timecard = t.context.timecard;
	const fixture = path.join(fixtures, 'blank.json');
	const data = await pify(fs.readFile)(fixture, 'utf8');
	await timecard.load(data);

	timecard.clockout().catch(err => {
		t.true('You must clockin before clocking out') > -1);
github algolia / talksearch-scraper / src / __tests__ / fileutils.js View on Github external
it('is a promise wrapper around glob', async () => {
      module._glob = null;
      const mockGlob = jest.fn().mockReturnValue('foo');

      const actual = await module.glob('pattern');

github algolia / talksearch-scraper / src / __tests__ / fileutils.js View on Github external
it('is a promise wrapper around fs.readFile', async () => {
      module._readFile = null;
      const mockReadFile = jest.fn().mockReturnValue('foo');

      const actual = await'filepath');

github googleapis / nodejs-error-reporting / system-test / utils.ts View on Github external

import {ChildProcess, fork, ForkOptions, spawn, SpawnOptions} from 'child_process';
import {mkdir, readFile, stat, Stats, writeFile} from 'fs';
import glob from 'glob';
import {ncp} from 'ncp';
import once from 'once';
import path from 'path';
import pify from 'pify';
import rimraf from 'rimraf';
import tmp from 'tmp';

export const BUILD_DIRECTORY = 'build';

export const globP: (pattern: string) => Promise = pify(glob);
export const ncpP: (src: string, dest: string) => Promise = pify(ncp);
export const readFileP: (path: string, encoding?: string) =>
    Promise = pify(readFile);
export const writeFileP: (path: string, data: string, encoding?: string) =>
    Promise = pify(writeFile);
export const statP: (path: string) => Promise = pify(stat);
export const tmpDirP: () => Promise = pify(tmp.dir);
export const rimrafP: (f: string) => Promise = pify(rimraf);
export const mkdirP: (path: string, mode?: number) => Promise =

export function nodule(nodule: string) {
  return path.relative(BUILD_DIRECTORY, `node_modules/${nodule}`);

export function existsP(path: string): Promise {
  return statP(path).then(
github electron-userland / electron-compile / test / compile-cache.js View on Github external
import './support.js';

import fs from 'fs';
import path from 'path';
import rimraf from 'rimraf';
import mkdirp from 'mkdirp';
import FileChangeCache from '../src/file-change-cache';
import CompileCache from '../src/compile-cache';
import pify from 'pify';

const pfs = pify(fs);

let testCount=0;

describe('The compile cache', function() {
  beforeEach(function() {
    this.appRootDir = path.join(__dirname, '..');
    this.fileChangeCache = new FileChangeCache(this.appRootDir);

    this.tempCacheDir = path.join(__dirname, `__compile_cache_${testCount++}`);
    this.fixture = new CompileCache(this.tempCacheDir, this.fileChangeCache);

  afterEach(function() {
github isomorphic-git / isomorphic-git / test / _helpers.js View on Github external
import fs from 'fs'
import temp from 'temp'
import pify from 'pify'

export const tmpdir = pify(cb => temp.mkdir(null, cb))
export const exists = fs.existsSync


Promisify a callback-style function

Latest version published 2 years ago

Package Health Score

73 / 100
Full package analysis

Popular pify functions