File tree Expand file tree Collapse file tree 3 files changed +45
-1
lines changed Expand file tree Collapse file tree 3 files changed +45
-1
lines changed Original file line number Diff line number Diff line change 11import { Command } from '@commander-js/extra-typings' ;
22import { getBuildCommand } from './build.js' ;
33import { getListCommand } from './list.js' ;
4- import { getLintCommand , getTscCommand } from './prebuild.js' ;
4+ import { getLintCommand , getPrebuildAllCommand , getTscCommand } from './prebuild.js' ;
55import getTemplateCommand from './template.js' ;
66import { getTestCommand } from './testing.js' ;
77
88export const getMainCommand = ( ) => new Command ( )
99 . addCommand ( getBuildCommand ( ) )
1010 . addCommand ( getLintCommand ( ) )
1111 . addCommand ( getListCommand ( ) )
12+ . addCommand ( getPrebuildAllCommand ( ) )
1213 . addCommand ( getTemplateCommand ( ) )
1314 . addCommand ( getTestCommand ( ) )
1415 . addCommand ( getTscCommand ( ) ) ;
Original file line number Diff line number Diff line change 66import pathlib from 'path' ;
77import { Command } from '@commander-js/extra-typings' ;
88import { resolveEitherBundleOrTab } from '../build/manifest.js' ;
9+ import { runPrebuild } from '../prebuild/index.js' ;
910import { formatLintResult , runEslint } from '../prebuild/lint.js' ;
1011import { formatTscResult , runTsc } from '../prebuild/tsc.js' ;
1112import { logCommandErrorAndExit } from './commandUtils.js' ;
@@ -63,3 +64,30 @@ export const getTscCommand = () => new Command('tsc')
6364 }
6465 }
6566 } ) ;
67+
68+ export const getPrebuildAllCommand = ( ) => new Command ( 'prebuild' )
69+ . argument ( '[directory]' , 'Directory to prebuild tasks in' , process . cwd ( ) )
70+ . option ( '--ci' )
71+ . action ( async ( directory , { ci } ) => {
72+ const fullyResolved = pathlib . resolve ( directory ) ;
73+ const asset = await resolveEitherBundleOrTab ( fullyResolved ) ;
74+
75+ if ( ! asset ) {
76+ logCommandErrorAndExit ( `No tab or bundle found at ${ fullyResolved } ` ) ;
77+ }
78+
79+ const { tsc, lint } = await runPrebuild ( asset ) ;
80+ console . log ( formatTscResult ( tsc ) ) ;
81+ console . log ( formatLintResult ( lint ) ) ;
82+
83+ [ tsc , lint ] . forEach ( ( { severity } ) => {
84+ switch ( severity ) {
85+ case 'warn' : {
86+ if ( ! ci ) return ;
87+ }
88+ case 'error' : {
89+ process . exit ( 1 ) ;
90+ }
91+ }
92+ } ) ;
93+ } ) ;
Original file line number Diff line number Diff line change @@ -50,3 +50,18 @@ export async function runBuilderWithPrebuild<T extends ResolvedBundle | Resolved
5050 lint : lintResult
5151 } ;
5252}
53+
54+ /**
55+ * Run just tsc and ESLint simultaneously without running any build tasks
56+ */
57+ export async function runPrebuild ( asset : ResolvedBundle | ResolvedTab ) {
58+ const [ tscResult , lintResult ] = await Promise . all ( [
59+ runTsc ( asset , false ) ,
60+ runEslint ( asset , false )
61+ ] ) ;
62+
63+ return {
64+ tsc : tscResult ,
65+ lint : lintResult
66+ } ;
67+ }
You can’t perform that action at this time.
0 commit comments