react-native/local-cli/link/link.js
function link(args, config) {
  var project;
  try {
    project = config.getProjectConfig();
  } catch (err) {
    log.error(
      'ERRPACKAGEJSON',
      'No package found. Are you sure it\'s a React Native project?'
    );
    return Promise.reject(err);
  }

  let packageName = args[0];
  // Check if install package by specific version (eg. package@latest)
  if (packageName !== undefined) {
    packageName = packageName.split('@')[0];
  }

  const dependencies = getDependencyConfig(
    config,
    packageName ? [packageName] : getProjectDependencies()
  );

  const assets = dedupeAssets(dependencies.reduce(
    (assets, dependency) => assets.concat(dependency.config.assets),
    project.assets
  ));

  const tasks = flatten(dependencies.map(dependency => [
    () => promisify(dependency.config.commands.prelink || commandStub),
    () => linkDependencyAndroid(project.android, dependency),
    () => linkDependencyIOS(project.ios, dependency),
    () => linkDependencyWindows(project.windows, dependency),
    () => promisify(dependency.config.commands.postlink || commandStub),
  ]));

  tasks.push(() => linkAssets(project, assets));

  return promiseWaterfall(tasks).catch(err => {
    log.error(
      `It seems something went wrong while linking. Error: ${err.message} \n`
      + 'Please file an issue here: https://github.com/facebook/react-native/issues'
    );
    throw err;
  });
}
function link(args, config) {
  var project;
  try {
    project = config.getProjectConfig();
  } catch (err) {
    log.error(
      'ERRPACKAGEJSON',
      'No package found. Are you sure it\'s a React Native project?'
    );
    return Promise.reject(err);
  }

  let packageName = args[0];
  // Check if install package by specific version (eg. package@latest)
  if (packageName !== undefined) {
    packageName = packageName.split('@')[0];
  }

  const dependencies = getDependencyConfig(
    config,
    packageName ? [packageName] : getProjectDependencies()
  );

  const assets = dedupeAssets(dependencies.reduce(
    (assets, dependency) => assets.concat(dependency.config.assets),
    project.assets
  ));

  const tasks = flatten(dependencies.map(dependency => [
    () => promisify(dependency.config.commands.prelink || commandStub),
    () => linkDependencyAndroid(project.android, dependency),
    () => linkDependencyIOS(project.ios, dependency),
    () => linkDependencyWindows(project.windows, dependency),
    () => promisify(dependency.config.commands.postlink || commandStub),
  ]));

  tasks.push(() => linkAssets(project, assets));

  return promiseWaterfall(tasks).catch(err => {
    log.error(
      `It seems something went wrong while linking. Error: ${err.message} \n`
      + 'Please file an issue here: https://github.com/facebook/react-native/issues'
    );
    throw err;
  });
}
function link ( args , config ) { var project ; try { project = config . getProjectConfig ( ) ; } catch ( err ) { log . error ( 'ERRPACKAGEJSON' , 'No package found. Are you sure it\'s a React Native project?' ) ; return Promise . reject ( err ) ; } let packageName = args [ 0 ] ; // Check if install package by specific version (eg. package@latest) if ( packageName !== undefined ) { packageName = packageName . split ( '@' ) [ 0 ] ; } const dependencies = getDependencyConfig ( config , packageName ? [ packageName ] : getProjectDependencies ( ) ) ; const assets = dedupeAssets ( dependencies . reduce ( ( assets , dependency ) => assets . concat ( dependency . config . assets ) , project . assets ) ) ; const tasks = flatten ( dependencies . map ( dependency => [ ( ) => promisify ( dependency . config . commands . prelink || commandStub ) , ( ) => linkDependencyAndroid ( project . android , dependency ) , ( ) => linkDependencyIOS ( project . ios , dependency ) , ( ) => linkDependencyWindows ( project . windows , dependency ) , ( ) => promisify ( dependency . config . commands . postlink || commandStub ) , ] ) ) ; tasks . push ( ( ) => linkAssets ( project , assets ) ) ; return promiseWaterfall ( tasks ) . catch ( err => { log . error ( ` ${ err . message } \n ` + 'Please file an issue here: https://github.com/facebook/react-native/issues' ) ; throw err ; } ) ; }
Updates project and links all dependencies to it

If optional argument [packageName] is provided, it's the only one that's checked
Updates project and links all dependencies to it