diff --git a/local-cli/__mocks__/chalk.js b/local-cli/__mocks__/chalk.js new file mode 100644 index 000000000..1376f2754 --- /dev/null +++ b/local-cli/__mocks__/chalk.js @@ -0,0 +1,33 @@ +/** + * 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 mockColor = () => { + return { + bold: () => { return { }; }, + }; +}; + +mockColor.bold = function() { + return {}; +}; + +module.exports = { + dim: s => s, + magenta: mockColor, + white: mockColor, + blue: mockColor, + yellow: mockColor, + green: mockColor, + bold: mockColor, + red: mockColor, + cyan: mockColor, + gray: mockColor, + black: mockColor, +}; diff --git a/local-cli/link/__tests__/link.spec.js b/local-cli/link/__tests__/link.spec.js index 0b697a8e8..9a3ccd1fc 100644 --- a/local-cli/link/__tests__/link.spec.js +++ b/local-cli/link/__tests__/link.spec.js @@ -1,3 +1,12 @@ +/** + * Copyright (c) 2013-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'; jest.autoMockOff(); @@ -5,6 +14,10 @@ jest.autoMockOff(); const sinon = require('sinon'); const log = require('npmlog'); const path = require('path'); +jest.setMock( + 'chalk', + { grey: (str) => str, } +); describe('link', () => { beforeEach(() => { diff --git a/local-cli/link/link.js b/local-cli/link/link.js index 33fc5871c..cb8c07443 100644 --- a/local-cli/link/link.js +++ b/local-cli/link/link.js @@ -1,7 +1,17 @@ +/** + * Copyright (c) 2013-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. + */ + const log = require('npmlog'); const path = require('path'); const uniq = require('lodash').uniq; const flatten = require('lodash').flatten; +const chalk = require('chalk'); const isEmpty = require('lodash').isEmpty; const promiseWaterfall = require('./promiseWaterfall'); @@ -30,7 +40,7 @@ const linkDependencyAndroid = (androidProject, dependency) => { const isInstalled = isInstalledAndroid(androidProject, dependency.name); if (isInstalled) { - log.info(`Android module ${dependency.name} is already linked`); + log.info(chalk.grey(`Android module ${dependency.name} is already linked`)); return null; } @@ -56,7 +66,7 @@ const linkDependencyIOS = (iOSProject, dependency) => { const isInstalled = isInstalledIOS(iOSProject, dependency.config.ios); if (isInstalled) { - log.info(`iOS module ${dependency.name} is already linked`); + log.info(chalk.grey(`iOS module ${dependency.name} is already linked`)); return; } @@ -82,7 +92,7 @@ const linkAssets = (project, assets) => { copyAssetsAndroid(assets, project.android.assetsPath); } - log.info(`Assets have been successfully linked to your project`); + log.info('Assets have been successfully linked to your project'); }; /** @@ -126,11 +136,11 @@ function link(args, config) { 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` + + 'Please file an issue here: https://github.com/facebook/react-native/issues' ); throw err; }); -}; +} module.exports = { func: link,