How to use the @parcel/utils.promisify function in @parcel/utils

To help you get started, we’ve selected a few @parcel/utils 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 parcel-bundler / parcel / packages / core / fs / src / fs.js View on Github external
const {promisify} = require('@parcel/utils');
const fs = require('fs');
const mkdirp = require('mkdirp');
const rimraf = require('rimraf');

exports.readFile = promisify(fs.readFile);
exports.writeFile = promisify(fs.writeFile);
exports.stat = promisify(fs.stat);
exports.readdir = promisify(fs.readdir);
exports.unlink = promisify(fs.unlink);
exports.rimraf = promisify(rimraf);
exports.realpath = async function(path) {
  const realpath = promisify(fs.realpath);
  try {
    path = await realpath(path);
  } catch (e) {
    // do nothing
  }
  return path;
};
exports.lstat = promisify(fs.lstat);

exports.exists = function(filename) {
  return new Promise(resolve => {
    fs.exists(filename, resolve);
github parcel-bundler / parcel / packages / core / fs / src / fs.js View on Github external
exports.realpath = async function(path) {
  const realpath = promisify(fs.realpath);
  try {
    path = await realpath(path);
  } catch (e) {
    // do nothing
  }
  return path;
};
exports.lstat = promisify(fs.lstat);
github parcel-bundler / parcel / packages / core / fs / src / fs.js View on Github external
const {promisify} = require('@parcel/utils');
const fs = require('fs');
const mkdirp = require('mkdirp');
const rimraf = require('rimraf');

exports.readFile = promisify(fs.readFile);
exports.writeFile = promisify(fs.writeFile);
exports.stat = promisify(fs.stat);
exports.readdir = promisify(fs.readdir);
exports.unlink = promisify(fs.unlink);
exports.rimraf = promisify(rimraf);
exports.realpath = async function(path) {
  const realpath = promisify(fs.realpath);
  try {
    path = await realpath(path);
  } catch (e) {
    // do nothing
  }
  return path;
};
exports.lstat = promisify(fs.lstat);

exports.exists = function(filename) {
  return new Promise(resolve => {
github parcel-bundler / parcel / packages / core / fs / src / NodeFS.js View on Github external
import fs from 'fs';
import ncp from 'ncp';
import mkdirp from 'mkdirp';
import rimraf from 'rimraf';
import {registerSerializableClass, promisify} from '@parcel/utils';
import watcher from '@parcel/watcher';
import packageJSON from '../package.json';

// Most of this can go away once we only support Node 10+, which includes
// require('fs').promises

const realpath = promisify(fs.realpath);

export class NodeFS implements FileSystem {
  readFile = promisify(fs.readFile);
  writeFile = promisify(fs.writeFile);
  copyFile = promisify(fs.copyFile);
  stat = promisify(fs.stat);
  readdir = promisify(fs.readdir);
  unlink = promisify(fs.unlink);
  utimes = promisify(fs.utimes);
  mkdirp = promisify(mkdirp);
  rimraf = promisify(rimraf);
  ncp = promisify(ncp);
  createReadStream = fs.createReadStream;
  createWriteStream = fs.createWriteStream;
  cwd = process.cwd;
  chdir = process.chdir;

  readFileSync = fs.readFileSync;
  statSync = fs.statSync;
  realpathSync = fs.realpathSync;
github parcel-bundler / parcel / packages / transformers / sass / src / SassTransformer.js View on Github external
async transform({asset, options, config, logger}) {
    await warnAboutNodeSassBeingUnsupported(asset.filePath, logger);
    let sass = await options.packageManager.require('sass', asset.filePath);
    const sassRender = promisify(sass.render.bind(sass));

    let css;
    try {
      css = (await sassRender(config)).css;
    } catch (err) {
      // Adapt the Error object for the reporter.
      err.fileName = err.file;
      err.loc = {
        line: err.line,
        column: err.column,
      };

      throw err;
    }

    asset.type = 'css';
github parcel-bundler / parcel / packages / core / fs / src / NodeFS.js View on Github external
// Most of this can go away once we only support Node 10+, which includes
// require('fs').promises

const realpath = promisify(fs.realpath);

export class NodeFS implements FileSystem {
  readFile = promisify(fs.readFile);
  writeFile = promisify(fs.writeFile);
  copyFile = promisify(fs.copyFile);
  stat = promisify(fs.stat);
  readdir = promisify(fs.readdir);
  unlink = promisify(fs.unlink);
  utimes = promisify(fs.utimes);
  mkdirp = promisify(mkdirp);
  rimraf = promisify(rimraf);
  ncp = promisify(ncp);
  createReadStream = fs.createReadStream;
  createWriteStream = fs.createWriteStream;
  cwd = process.cwd;
  chdir = process.chdir;

  readFileSync = fs.readFileSync;
  statSync = fs.statSync;
  realpathSync = fs.realpathSync;
  existsSync = fs.existsSync;
  readdirSync = (fs.readdirSync: any);

  async realpath(originalPath: string): Promise {
    try {
      return await realpath(originalPath, 'utf8');
    } catch (e) {
      // do nothing
github parcel-bundler / parcel / packages / core / fs / src / NodeFS.js View on Github external
import fs from 'fs';
import ncp from 'ncp';
import mkdirp from 'mkdirp';
import rimraf from 'rimraf';
import {registerSerializableClass, promisify} from '@parcel/utils';
import watcher from '@parcel/watcher';
import packageJSON from '../package.json';

// Most of this can go away once we only support Node 10+, which includes
// require('fs').promises

const realpath = promisify(fs.realpath);

export class NodeFS implements FileSystem {
  readFile = promisify(fs.readFile);
  writeFile = promisify(fs.writeFile);
  copyFile = promisify(fs.copyFile);
  stat = promisify(fs.stat);
  readdir = promisify(fs.readdir);
  unlink = promisify(fs.unlink);
  utimes = promisify(fs.utimes);
  mkdirp = promisify(mkdirp);
  rimraf = promisify(rimraf);
  ncp = promisify(ncp);
  createReadStream = fs.createReadStream;
  createWriteStream = fs.createWriteStream;
  cwd = process.cwd;
  chdir = process.chdir;

  readFileSync = fs.readFileSync;
  statSync = fs.statSync;
github parcel-bundler / parcel / packages / core / fs / src / fs.js View on Github external
const {promisify} = require('@parcel/utils');
const fs = require('fs');
const mkdirp = require('mkdirp');
const rimraf = require('rimraf');

exports.readFile = promisify(fs.readFile);
exports.writeFile = promisify(fs.writeFile);
exports.stat = promisify(fs.stat);
exports.readdir = promisify(fs.readdir);
exports.unlink = promisify(fs.unlink);
exports.rimraf = promisify(rimraf);
exports.realpath = async function(path) {
  const realpath = promisify(fs.realpath);
  try {
    path = await realpath(path);
  } catch (e) {
    // do nothing
  }
  return path;
};
exports.lstat = promisify(fs.lstat);
github parcel-bundler / parcel / packages / core / fs / src / fs.js View on Github external
const {promisify} = require('@parcel/utils');
const fs = require('fs');
const mkdirp = require('mkdirp');
const rimraf = require('rimraf');

exports.readFile = promisify(fs.readFile);
exports.writeFile = promisify(fs.writeFile);
exports.stat = promisify(fs.stat);
exports.readdir = promisify(fs.readdir);
exports.unlink = promisify(fs.unlink);
exports.rimraf = promisify(rimraf);
exports.realpath = async function(path) {
  const realpath = promisify(fs.realpath);
  try {
    path = await realpath(path);
  } catch (e) {
    // do nothing
  }
  return path;
};
exports.lstat = promisify(fs.lstat);

exports.exists = function(filename) {
github parcel-bundler / parcel / packages / core / fs / src / NodeFS.js View on Github external
Options as WatcherOptions,
  AsyncSubscription,
} from '@parcel/watcher';

import fs from 'fs';
import ncp from 'ncp';
import mkdirp from 'mkdirp';
import rimraf from 'rimraf';
import {registerSerializableClass, promisify} from '@parcel/utils';
import watcher from '@parcel/watcher';
import packageJSON from '../package.json';

// Most of this can go away once we only support Node 10+, which includes
// require('fs').promises

const realpath = promisify(fs.realpath);

export class NodeFS implements FileSystem {
  readFile = promisify(fs.readFile);
  writeFile = promisify(fs.writeFile);
  copyFile = promisify(fs.copyFile);
  stat = promisify(fs.stat);
  readdir = promisify(fs.readdir);
  unlink = promisify(fs.unlink);
  utimes = promisify(fs.utimes);
  mkdirp = promisify(mkdirp);
  rimraf = promisify(rimraf);
  ncp = promisify(ncp);
  createReadStream = fs.createReadStream;
  createWriteStream = fs.createWriteStream;
  cwd = process.cwd;
  chdir = process.chdir;