How to use the ember-cli/lib/ext/promise.reject function in ember-cli

To help you get started, we’ve selected a few ember-cli 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 duizendnegen / ember-cli-deploy-azure / lib / azure-assets.js View on Github external
init: function() {
    CoreObject.prototype.init.apply(this, arguments);
    if (!this.config) {
      return Promise.reject(new SilentError('You have to pass a config!'));
    }

    var config = this.config.assets;

    // be transparant to either passing a connectionString or the storageAccount + storageAccessKey
    if(config.connectionString) {
      this.client = azure.createBlobService(config.connectionString);
    } else if (config.storageAccount && config.storageAccessKey) {
      this.client = azure.createBlobService(config.storageAccount, config.storageAccessKey);
    } else {
      console.error("No connection string or storage account plus access key set for this Azure deployment.");
      return Promise.reject(new SilentError('No connection string or storage account plus access key set for this Azure deployment.'));
    }

    // if a storage container name is defined in the config, use it instead of the default
    if(config.containerName) {
      AZURE_CONTAINER_NAME = config.containerName;
    }
  },
github nathanhammond / ember-capture / lib / tasks / server / capture-server.js View on Github external
.then(function(base64) {
          // Prevent duplicate screenshots.
          if (base64 === previousScreenshot[browser]) {
            return Promise.reject('Duplicate.')
          }

          previousScreenshot[browser] = base64;
          return base64;
        })
        .then(function(base64) {
github achambers / ember-cli-deploy-original / lib / validators / index-config.js View on Github external
config = config || {};

  var indexConfig = config.index;
  var defaultIndexConfig = {
    host: 'localhost',
    port: '6379',
    password: null
  };

  if (!config.distDir) {
    config.distDir = 'dist';
  }

  if (!indexConfig) {
    var message = chalk.yellow(errorMessage.replace('{0}', 'index'));
    return Promise.reject(new SilentError(message));
  }

  for (var prop in defaultIndexConfig) {
    if (!indexConfig.hasOwnProperty(prop) || indexConfig[prop] == null) {
      indexConfig[prop] = defaultIndexConfig[prop];
    }
  }

  return Promise.resolve(config);
};
github isleofcode / corber / lib / tasks / open.js View on Github external
module.exports = function(project, platform, application) {
  var projectPath, command;
  if (platform === 'ios') {
    projectPath = path.join(project.root, 'cordova', 'platforms/ios/*.xcodeproj');
  } else if (platform === 'android') {
    projectPath = path.join(project.root, 'cordova', 'platforms/android/.project');
  } else {
    return Promise.reject(new Error('The ' + platform + ' platform is not supported. Please use "ios" or "android"'));
  }

  var command = getOpenCommand(projectPath, application);

  return runCommand(command, 'Opening ' + platform + ' project with the default application');
};
github achambers / ember-cli-deploy-original / lib / utilities / s3-uploader.js View on Github external
S3Uploader.prototype.uploadFile = function(options) {
  options = options || {};

  var bucket = this.bucket;
  var filePath = options.filePath;
  var fullPath = options.cwd + '/' + filePath;

  if (!fs.existsSync(fullPath)) {
    var message = chalk.red('File at path: \'' + fullPath + '\' does not exist\n');

    return Promise.reject(message);
  }

  var data = fs.readFileSync(fullPath);
  var contentType = mime.lookup(fullPath);

  var params = {
    Bucket: bucket,
    ACL: 'public-read',
    Body: data,
    ContentType: contentType,
    Key: filePath
  };

  var client = this.client;

  return new Promise(function(resolve, reject) {
github ember-cli-deploy / ember-cli-deploy / lib / utilities / configuration-reader.js View on Github external
read: function(){
    var self = this;
    var configResult;
    try {
      configResult = require(this.pathToConfig)(this.environment);
    } catch(e) {
      this.ui.writeError(e);
      return Promise.reject(new Error('Cannot load configuration file \'' + this.pathToConfig + '\'. Note that the default location of the ember-cli-deploy config file is now \''+ self.defaultConfigPath + '\''));
    }

    return Promise.resolve(configResult).then(function(config){
      if (!Object.keys(config).length) {
        throw new SilentError('You are using the `' + self.environment + '` environment but have not specified any configuration.' +
          '\n\nPlease add a `' + self.environment + '` section to your `config/deploy.js` file.' +
          '\n\nFor more information, go to: `https://github.com/ember-cli/ember-cli-deploy#config-file`');
      }
      return new Config({
        project: self.project,
        rawConfig: config
      });
    });
  }
});
github bobisjan / ember-format / blueprints / locale / index.js View on Github external
beforeInstall: function(options) {
    var ui = this.ui;
    var code = this.localeCodeFor(options);
    var locale = this.localeFor(code);

    if (!this.isSupportedLocale(locale)) {
      return Promise.reject(new SilentError('The locale `' + code + '` is not supported.'));
    }

    var displayPath = this.dataDisplayPath(code);
    var fullPath = path.join(this.project.root, displayPath);
    var contents = 'export default ' + serialize(locale) + ';';

    return writeFile(fullPath, contents).then(function() {
      ui.writeLine('  ' + chalk.green('create') + ' ' + displayPath);
    });
  },
github Vestorly / ember-cli-s3-sync / lib / utils / s3-tool.js View on Github external
}, function(err) {
        ui.writeLine(chalk.red('Upload error: ') + fullPath);
        return Promise.reject(err);
      })
      .finally(function() {
github ember-cli-deploy / ember-cli-deploy / utilities / index / redis.js View on Github external
_printErrorMessage: function(message) {
    return Promise.reject(new SilentError(message));
  },
github Vestorly / ember-cli-s3-sync / blueprints / config-s3 / index.js View on Github external
return this.ui.prompt([disclaimer]).then(function(results) {
        if (results.understand) {
          return Promise.resolve();
        } else {
          return Promise.reject('deploy/config.js file not created.');
        }
      });
  },