@@ -10,6 +10,9 @@ import {Add} from './add.js';
1010import { Install } from './install.js' ;
1111import Lockfile from '../../lockfile/wrapper.js' ;
1212
13+ const tty = require ( 'tty' ) ;
14+ const semver = require ( 'semver' ) ;
15+
1316export const requireLockfile = true ;
1417
1518export function setFlags ( commander : Object ) {
@@ -29,14 +32,16 @@ type InquirerResponses<K, T> = {[key: K]: Array<T>};
2932
3033// Prompt user with Inquirer
3134async function prompt ( choices ) : Promise < Array < Dependency >> {
35+ let pageSize ;
36+ if ( process . stdout instanceof tty . WriteStream ) {
37+ pageSize = process . stdout . rows - 2 ;
38+ }
3239 const answers : InquirerResponses < 'packages' , Dependency > = await inquirer . prompt ( [ {
3340 name : 'packages' ,
3441 type : 'checkbox' ,
3542 message : 'Choose which packages to update.' ,
3643 choices,
37- // Couldn't make it work, I guess I'm missing something here
38- // $FlowFixMe: https://github.com/facebook/flow/blob/f41e66e27b227235750792c34f5a80f38bde6320/lib/node.js#L1197
39- pageSize : process . stdout . rows - 2 ,
44+ pageSize,
4045 validate : ( answer ) => ! ! answer . length || 'You must choose at least one package.' ,
4146 } ] ) ;
4247 return answers . packages ;
@@ -74,17 +79,11 @@ export async function run(
7479 return ( { name, current, wanted, latest, hint} ) ;
7580 } ) ) ) ;
7681
77- const isDepOld = ( { latest, current} ) => latest !== current ;
82+ const isDepOld = ( { latest, current} ) => latest !== 'exotic' && semver . lt ( current , latest ) ;
7883 const isDepExpected = ( { current, wanted} ) => current === wanted ;
84+ const orderByExpected = ( depA , depB ) => isDepExpected ( depA ) && ! isDepExpected ( depB ) ? 1 : - 1 ;
7985
80- const outdatedDeps = allDeps
81- . filter ( isDepOld )
82- . sort ( ( depA , depB ) => {
83- if ( isDepExpected ( depA ) && ! isDepExpected ( depB ) ) {
84- return 1 ;
85- }
86- return - 1 ;
87- } ) ;
86+ const outdatedDeps = allDeps . filter ( isDepOld ) . sort ( orderByExpected ) ;
8887
8988 const getNameFromHint = ( hint ) => hint ? `${ hint } Dependencies` : 'dependencies' ;
9089
0 commit comments