Skip to content

Commit

Permalink
refactor(logging): use info for some more log output (#418)
Browse files Browse the repository at this point in the history
* refactor: use info for some more log output
* update some test scripts
* update test snapshots
  • Loading branch information
Chris Brody authored Feb 18, 2021
1 parent 784e07c commit d3e8047
Show file tree
Hide file tree
Showing 12 changed files with 28 additions and 32 deletions.
4 changes: 2 additions & 2 deletions lib/cli-command.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { log, error } = require('console');
const { info, error } = require('console');

const emoji = require('node-emoji');

Expand Down Expand Up @@ -71,7 +71,7 @@ module.exports = {
const rootModuleName = createOptions.moduleName;

return createLibraryModule(createOptions).then(() => {
log(`
info(`
${emoji.get('books')} Created library module ${rootModuleName} in \`./${rootModuleName}\`.
${emoji.get('clock9')} It took ${Date.now() - beforeCreation}ms.
${postCreateInstructions(createOptions)}`);
Expand Down
6 changes: 3 additions & 3 deletions lib/lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const path = require('path');

// External imports:

const { log, info, warn, error } = require('console');
const { info, warn, error } = require('console');

// default execa object
const execaDefault = require('execa');
Expand Down Expand Up @@ -274,7 +274,7 @@ exampleReactNativeVersion: ${exampleReactNativeVersion}

// pod tool is needed at this point for iOS
try {
log(
info(
`check for valid pod version in ${iosExampleAppProjectPath}`);

commandSync('pod --version', podCommandOptions);
Expand All @@ -283,7 +283,7 @@ exampleReactNativeVersion: ${exampleReactNativeVersion}
throw (e);
}

log(`running pod install in ${iosExampleAppProjectPath}`);
info(`running pod install in ${iosExampleAppProjectPath}`);

try {
commandSync('pod install', podCommandOptions);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ yarn-error.log
",
},
Object {
"log": Array [
"info": Array [
"
📚 Created library module react-native-alice-bobbi in \`./react-native-alice-bobbi\`.
🕘 It took XXX.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,13 @@ jest.mock('fs-extra', () => ({
}));
jest.mock('console', () => ({
info: (...args) => {
mockpushit({ info: [].concat(args) });
},
log: (...args) => {
mockpushit({
// TBD EXTRA WORKAROUND HACK for non-deterministic elapsed time in log
log: args.map(line => line.replace(/It took.*s/g, 'It took XXX'))
info: args.map(line => line.replace(/It took.*s/g, 'It took XXX'))
});
},
// console.log is no longer expected
// log: (...args) => ...
warn: (...args) => {
mockpushit({ warn: [].concat(args) });
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ yarn-error.log
",
},
Object {
"log": Array [
"info": Array [
"
📚 Created library module react-native-alice-bobbi in \`./react-native-alice-bobbi\`.
🕘 It took XXX.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,13 @@ jest.mock('fs-extra', () => ({
}));
jest.mock('console', () => ({
info: (...args) => {
mockpushit({ info: [].concat(args) });
},
log: (...args) => {
mockpushit({
// TBD EXTRA WORKAROUND HACK for non-deterministic elapsed time in log
log: args.map(line => line.replace(/It took.*s/g, 'It took XXX'))
info: args.map(line => line.replace(/It took.*s/g, 'It took XXX'))
});
},
// console.log is no longer expected
// log: (...args) => ...
warn: (...args) => {
mockpushit({ warn: [].concat(args) });
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,13 @@ jest.mock('fs-extra', () => ({
}));
jest.mock('console', () => ({
info: (...args) => {
mockpushit({ info: [].concat(args) });
},
log: (...args) => {
mockpushit({
// TBD EXTRA WORKAROUND HACK for non-deterministic elapsed time in log
log: args.map(line => line.replace(/It took.*s/g, 'It took XXX'))
info: args.map(line => line.replace(/It took.*s/g, 'It took XXX'))
});
},
// console.log is no longer expected
// log: (...args) => ...
warn: (...args) => {
mockpushit({ warn: [].concat(args) });
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1180,7 +1180,7 @@ const styles = StyleSheet.create({
},
},
Object {
"log": Array [
"info": Array [
"check for valid pod version in ./react-native-test-package/example/ios",
],
},
Expand All @@ -1192,7 +1192,7 @@ const styles = StyleSheet.create({
},
},
Object {
"log": Array [
"info": Array [
"running pod install in ./react-native-test-package/example/ios",
],
},
Expand All @@ -1204,7 +1204,7 @@ const styles = StyleSheet.create({
},
},
Object {
"log": Array [
"info": Array [
"
📚 Created library module react-native-test-package in \`./react-native-test-package\`.
🕘 It took XXX.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,13 @@ jest.mock('execa', () => ({
}));
jest.mock('console', () => ({
info: (...args) => {
mockpushit({ info: [].concat(args) });
},
log: (...args) => {
mockpushit({
// TBD EXTRA WORKAROUND HACK for non-deterministic elapsed time in log
log: args.map(line => line.replace(/It took.*s/g, 'It took XXX'))
info: args.map(line => line.replace(/It took.*s/g, 'It took XXX'))
});
},
// console.log is no longer expected
// log: (...args) => ...
warn: (...args) => {
mockpushit({ warn: [].concat(args) });
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -966,7 +966,7 @@ const styles = StyleSheet.create({
},
},
Object {
"log": Array [
"info": Array [
"check for valid pod version in ./react-native-alice-bobbi/example/ios",
],
},
Expand All @@ -978,7 +978,7 @@ const styles = StyleSheet.create({
},
},
Object {
"log": Array [
"info": Array [
"running pod install in ./react-native-alice-bobbi/example/ios",
],
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -966,7 +966,7 @@ const styles = StyleSheet.create({
},
},
Object {
"log": Array [
"info": Array [
"check for valid pod version in ./react-native-alice-bobbi/example/ios",
],
},
Expand All @@ -978,7 +978,7 @@ const styles = StyleSheet.create({
},
},
Object {
"log": Array [
"info": Array [
"running pod install in ./react-native-alice-bobbi/example/ios",
],
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1071,7 +1071,7 @@ const styles = StyleSheet.create({
},
},
Object {
"log": Array [
"info": Array [
"check for valid pod version in ./react-native-alice-bobbi/demo/ios",
],
},
Expand All @@ -1083,7 +1083,7 @@ const styles = StyleSheet.create({
},
},
Object {
"log": Array [
"info": Array [
"running pod install in ./react-native-alice-bobbi/demo/ios",
],
},
Expand Down

0 comments on commit d3e8047

Please sign in to comment.