Martín Bigio bcf762af60 Move files from packager/ to local-cli
Summary: public

This is not only to put the files on a place where it makes more sense but also to allow to use ES6 features on them as `/packager` is not whitelisted on `babel`.

Reviewed By: mkonicek

Differential Revision: D2577267

fb-gh-sync-id: b69a17c0aad349a3eda987e33d1778d97a8e1549
2015-10-26 15:38:14 -07:00

64 lines
1.5 KiB
JavaScript

/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
'use strict';
const parseCommandLine = require('../util/parseCommandLine');
const path = require('path');
const Promise = require('promise');
const yeoman = require('yeoman-environment');
/**
* Generates the template for the given platform.
*/
function generate(argv, config) {
return new Promise((resolve, reject) => {
_generate(argv, config, resolve, reject);
});
}
function _generate(argv, config, resolve, reject) {
const args = parseCommandLine([{
command: 'platform',
description: 'Platform (ios|android)',
type: 'string',
required: true,
},
{
command: 'project-path',
description: 'Path to the project directory',
type: 'string',
required: true,
},
{
command: 'project-name',
description: 'Name of the project',
type: 'string',
required: true,
}], argv);
const oldCwd = process.cwd();
process.chdir(args['project-path']);
const env = yeoman.createEnv();
env.register(path.join(__dirname, '../generator'), 'react:app');
env.run(
['react:app', args['project-name']],
{
'skip-ios': args.platform !== 'ios',
'skip-android': args.platform !== 'android'
},
() => {
process.chdir(oldCwd);
resolve();
}
);
}
module.exports = generate;