2017-02-02 13:09:53 +00:00
|
|
|
/**
|
|
|
|
* Copyright (c) 2015-present, Facebook, Inc.
|
|
|
|
*
|
2018-02-17 02:24:55 +00:00
|
|
|
* This source code is licensed under the MIT license found in the
|
|
|
|
* LICENSE file in the root directory of this source tree.
|
2017-02-02 13:09:53 +00:00
|
|
|
*/
|
|
|
|
'use strict';
|
|
|
|
|
2016-05-20 11:52:08 +00:00
|
|
|
const spawnSync = require('child_process').spawnSync;
|
|
|
|
const log = require('npmlog');
|
2017-02-02 13:09:53 +00:00
|
|
|
const PackageManager = require('../util/PackageManager');
|
2016-05-20 11:52:08 +00:00
|
|
|
const spawnOpts = {
|
|
|
|
stdio: 'inherit',
|
|
|
|
stdin: 'inherit',
|
|
|
|
};
|
|
|
|
|
|
|
|
log.heading = 'rnpm-install';
|
|
|
|
|
2016-08-22 15:56:14 +00:00
|
|
|
function install(args, config) {
|
2016-05-20 11:52:08 +00:00
|
|
|
const name = args[0];
|
|
|
|
|
2017-02-02 13:09:53 +00:00
|
|
|
let res = PackageManager.add(name);
|
2016-05-20 11:52:08 +00:00
|
|
|
|
|
|
|
if (res.status) {
|
|
|
|
process.exit(res.status);
|
|
|
|
}
|
|
|
|
|
2017-02-02 13:09:53 +00:00
|
|
|
res = spawnSync('react-native', ['link', name], spawnOpts);
|
2016-05-20 11:52:08 +00:00
|
|
|
|
|
|
|
if (res.status) {
|
|
|
|
process.exit(res.status);
|
|
|
|
}
|
|
|
|
|
|
|
|
log.info(`Module ${name} has been successfully installed & linked`);
|
2017-02-02 13:09:53 +00:00
|
|
|
}
|
2016-08-22 15:56:14 +00:00
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
func: install,
|
|
|
|
description: 'install and link native dependencies',
|
|
|
|
name: 'install <packageName>',
|
|
|
|
};
|