File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -3,11 +3,19 @@ import fs from 'fs';
33import path from 'path' ;
44import { load } from '../data.js' ;
55
6- const city = process . argv [ 2 ] ;
6+ const args = process . argv . slice ( 2 ) ;
7+ const include = args . filter ( a => ! a . startsWith ( '-' ) ) ;
8+ const exclude = args . filter ( a => a . startsWith ( '-' ) ) . map ( a => a . slice ( 1 ) ) ;
79const { places } = load ( ) ;
8- const toCheck = places . filter ( p => p . google_maps && ! p . closed && ( ! city || p . city === city ) ) ;
10+ const toCheck = places . filter ( p => {
11+ if ( ! p . google_maps || p . closed ) return false ;
12+ if ( exclude . includes ( p . city ) ) return false ;
13+ if ( include . length > 0 ) return include . includes ( p . city ) ;
14+ return true ;
15+ } ) ;
916
10- console . log ( `Found ${ toCheck . length } non-closed cafes to check${ city ? ` in ${ city } ` : '' } .\n` ) ;
17+ const label = include . length ? ` in ${ include . join ( ', ' ) } ` : exclude . length ? ` excluding ${ exclude . join ( ', ' ) } ` : '' ;
18+ console . log ( `Found ${ toCheck . length } non-closed cafes to check${ label } .\n` ) ;
1119
1220async function checkPlace ( browser , url ) {
1321 const page = await browser . newPage ( ) ;
You can’t perform that action at this time.
0 commit comments