How to use the common-errors.TypeError function in common-errors

To help you get started, we’ve selected a few common-errors 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 pandawing / node-run-yo / lib / mv-promised.js View on Github external
return new Promise(function (resolve, reject) {
    if (!value) {
      reject(new errors.TypeError('requires value[source], value[dest]'));
      return;
    }
    // FIXME
    if ([value['source'], value['dest']].some(function (key) {
      return key === null || key === '' || key === '.' || key === '/';
    })) {
      reject(new errors.ArgumentError('input is not allowed'));
      return;
    }

    mv(value['source'], value['dest'], { mkdirp: true }, function (err) {
      if (err) {
        reject(err);
        return;
      }
      resolve();
github pandawing / node-run-yo / lib / generator-name.js View on Github external
return new Promise(function (resolve, reject) {
    if (!value) {
      reject(new errors.TypeError('generator name must be string'));
      return;
    }
    if (!isPackage(value)) {
      reject(new errors.ArgumentError('this is not package name: ' + value));
      return;
    } else {
      if (isScopedPackage(value)) {
        var split = value.split('/');
        removeGeneratorPrefix(split[1], function (err, data) {
          if (err) {
            reject(err);
            return;
          }
          resolve(split[0] + '/' + data);
          return;
        });
github pandawing / node-run-yo / lib / pick-target.js View on Github external
module.exports = function (input, cb) {
  if (type(input) !== 'string') {
    cb(new errors.TypeError('input requires string'), null);
    return;
  }
  var split = removeTrailingSeparator(path.normalize(input)).split(path.sep);
  var inputLast = split[split.length - 1];
  if (['', '.', '..'].some(function (value) {
    return inputLast === value;
  })) {
    cb(new errors.ArgumentError('input is not allowed: ' + prettyFormat(inputLast)), null);
    return;
  }
  cb(null, inputLast);
};
github pandawing / node-run-yo / lib / lnfs-promised.js View on Github external
module.exports = function (value) {
  if (!value) {
    return Promise.reject(new errors.TypeError('requires value[src], value[dest]'));
  }
  if(value['src'] === null || value['src'] === '' || value['src'] === '.' || value['src'] === '/') {
    return Promise.reject(new errors.ArgumentError('input is not allowed: ' + value['src']));
  }
  if(value['dest'] === null || value['dest'] === '' || value['dest'] === '.' || value['dest'] === '/') {
    return Promise.reject(new errors.ArgumentError('input is not allowed: ' + value['dest']));
  }
  return lnfs(value['src'], value['dest']);
};