Skip to content

Commit 788d03a

Browse files
author
Ahmad Awais
committed
🐛 FIX: Update Notifier
1 parent 94817a8 commit 788d03a

8 files changed

Lines changed: 19 additions & 74 deletions

File tree

packages/babel-preset-cgb/index.js

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,7 @@
55
// Update notifier.
66
const updateNotifier = require( 'update-notifier' );
77
const pkg = require( './package.json' );
8-
const notifier = updateNotifier( {
9-
pkg: pkg,
10-
// updateCheckInterval: 1000 * 60 * 60 * 24, // 1 day.
11-
} );
12-
13-
if ( notifier.update ) {
14-
notifier.notify();
15-
process.exit( 0 );
16-
}
8+
updateNotifier( { pkg } ).notify();
179

1810
module.exports = {
1911
presets: [

packages/cgb-dev-utils/clearConsole.js

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,7 @@
1111
// Update notifier.
1212
const updateNotifier = require( 'update-notifier' );
1313
const pkg = require( './package.json' );
14-
const notifier = updateNotifier( {
15-
pkg: pkg,
16-
// updateCheckInterval: 1000 * 60 * 60 * 24, // 1 day
17-
} );
18-
19-
if ( notifier.update ) {
20-
notifier.notify();
21-
process.exit( 0 );
22-
}
14+
updateNotifier( { pkg } ).notify();
2315

2416
/**
2517
* Cross platform clear console.

packages/cgb-dev-utils/crossSpawn.js

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,7 @@
1010
// Update notifier.
1111
const updateNotifier = require( 'update-notifier' );
1212
const pkg = require( './package.json' );
13-
const notifier = updateNotifier( {
14-
pkg: pkg,
15-
updateCheckInterval: 1000 * 60 * 60 * 24, // 1 day.
16-
} );
17-
18-
if ( notifier.update ) {
19-
notifier.notify();
20-
process.exit( 0 );
21-
}
13+
updateNotifier( { pkg } ).notify();
2214

2315
const crossSpawn = require( 'cross-spawn' );
2416

packages/cgb-dev-utils/formatWebpackMessages.js

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,7 @@
1010
// Update notifier.
1111
const updateNotifier = require( 'update-notifier' );
1212
const pkg = require( './package.json' );
13-
const notifier = updateNotifier( {
14-
pkg: pkg,
15-
updateCheckInterval: 1000 * 60 * 60 * 24, // 1 day.
16-
} );
17-
18-
if ( notifier.update ) {
19-
notifier.notify();
20-
process.exit( 0 );
21-
}
13+
updateNotifier( { pkg } ).notify();
2214

2315
// WARNING: this code is untranspiled and is used in browser too.
2416
// Please make sure any changes are in ES5 or contribute a Babel compile step.

packages/cgb-scripts/bin/cgb-scripts.js

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,8 @@
33

44
// Update notifier.
55
const updateNotifier = require( 'update-notifier' );
6-
const pkg = require( '../package.json' );
7-
const notifier = updateNotifier( {
8-
pkg: pkg,
9-
// updateCheckInterval: 1000 * 60 * 60 * 24, // 1 day.
10-
} );
11-
12-
if ( notifier.update ) {
13-
notifier.notify();
14-
process.exit( 0 );
15-
}
6+
const pkg = require( './package.json' );
7+
updateNotifier( { pkg } ).notify();
168

179
const spawn = require( 'cgb-dev-utils/crossSpawn' );
1810
const args = process.argv.slice( 2 );

packages/cgb-scripts/scripts/eject.js

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ inquirer
8383
}
8484

8585
// Checks passed now let's start ejecting.
86-
console.log( '\n\n' + chalk.black.bgGreen( ' Ejecting...' ) );
86+
console.log( '\n\n' + chalk.black.bgGreen( ' Ejecting...' ) );
8787

8888
const ownPath = paths.ownPath;
8989
const appPath = paths.appPath;
@@ -123,8 +123,8 @@ inquirer
123123
files.forEach( verifyAbsent );
124124

125125
console.log(
126-
'\n\n 👉 ',
127-
`${ chalk.black.bgYellow( ' Copying files to your plugin... ' ) }`,
126+
'\n 👉 ',
127+
`${ chalk.black.bgYellow( ' Copying files to your plugin... \n' ) }`,
128128
`${ chalk.dim( 'In the directory: ', appPath ) }`,
129129
'\n'
130130
);
@@ -161,16 +161,14 @@ inquirer
161161
fs.writeFileSync( file.replace( ownPath, appPath ), content );
162162
} );
163163

164-
console.log();
165-
166164
// Select cgb-scripts/package.json file.
167165
const ownPackage = require( path.join( ownPath, 'package.json' ) );
168166

169167
// Assume a file called package.json file in current folder.
170168
const appPackage = require( path.join( appPath, 'package.json' ) );
171169

172170
console.log(
173-
'\n\n 👉 ',
171+
'\n 👉 ',
174172
`${ chalk.black.bgYellow( ' Updating the dependencies... ' ) }`,
175173
'\n'
176174
);
@@ -216,11 +214,10 @@ inquirer
216214
appPackage.dependencies[ key ] = unsortedDependencies[ key ];
217215
} );
218216
console.log( ` ♻ ${ green( 'Sorting... ' ) }` );
219-
console.log();
220217

221218
// Update the scripts.
222219
console.log(
223-
'\n\n 👉 ',
220+
'\n 👉 ',
224221
`${ chalk.black.bgYellow( ' Updating the scripts... ' ) }`,
225222
'\n'
226223
);
@@ -247,9 +244,8 @@ inquirer
247244
} );
248245
} );
249246

250-
console.log();
251247
console.log(
252-
'\n\n 👉 ',
248+
'\n 👉 ',
253249
`${ chalk.black.bgYellow( ' Configuring package.json... ' ) }`,
254250
'\n'
255251
);
@@ -308,7 +304,6 @@ inquirer
308304
path.join( appPath, 'package.json' ),
309305
JSON.stringify( appPackage, null, 2 ) + '\n'
310306
);
311-
console.log();
312307

313308
// "Don't destroy what isn't ours".
314309
if ( ownPath.indexOf( appPath ) === 0 ) {
@@ -350,11 +345,9 @@ inquirer
350345
} );
351346
}
352347
console.log( '\n\n✅ ', chalk.black.bgGreen( ' Ejected successfully!' ), '\n' );
353-
console.log();
354348

355349
console.log(
356-
green( 'Please consider sharing why you ejected in this survey:' )
350+
green( 'Kindly, consider sharing why you ejected in this survey:\n' )
357351
);
358-
console.log( green( ' https://goo.gl/forms/T901kvHr1kNsJGaJ3 ' ) );
359-
console.log();
352+
console.log( green( '→ https://goo.gl/forms/T901kvHr1kNsJGaJ3 \n' ) );
360353
} );

packages/create-guten-block/createGutenBlock.js

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,6 @@ const resolvePkg = require( 'resolve-pkg' );
88
const template = resolvePkg( 'cgb-scripts/template', { cwd: __dirname } );
99
const directoryExists = require( 'directory-exists' );
1010

11-
// Update notifier.
12-
const updateNotifier = require( 'update-notifier' );
13-
const pkg = require( './package.json' );
14-
const notifier = updateNotifier( {
15-
pkg: pkg,
16-
updateCheckInterval: 1000 * 60 * 60 * 24, // 1 day.
17-
} );
18-
19-
if ( notifier.update ) {
20-
notifier.notify();
21-
process.exit( 0 );
22-
}
23-
2411
/**
2512
* Cross platform clear console.
2613
*/

packages/create-guten-block/index.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,5 +53,10 @@ if ( major < 8 ) {
5353
process.exit( 1 );
5454
}
5555

56+
// Update notifier.
57+
const updateNotifier = require( 'update-notifier' );
58+
const pkg = require( './package.json' );
59+
updateNotifier( { pkg } ).notify();
60+
5661
// Otherwise, run the app.
5762
require( './createGutenBlock' );

0 commit comments

Comments
 (0)