import { Command , flags } from "@oclif/command" ; const { NodePackageManager } = require ( "@parcel/package-manager" ) ; const { NodeFS } = require ( "@parcel/fs" ) ; import { normalizeOptions } from "../normalizeOptions" ; export default class Serve extends Command { static description = "describe the command here" ; static examples = [ `$ rincewind build # production build of a rincewind app` ] ; static aliases = [ "develop" , "dev" ] ; static flags = { help : flags . help ( { char : "h" } ) , "no-minify" : flags . boolean ( { default : false } ) , "no-scope-hoisting" : flags . boolean ( { default : false } ) } ; static args = [ { name : "file" } ] ; async run ( ) { const { args , flags } = this . parse ( Serve ) ; let Parcel = require ( "@parcel/core" ) . default ; let packageManager = new NodePackageManager ( new NodeFS ( ) ) ; let defaultConfig = await packageManager . require ( "@parcel/config-default" , __filename ) ; let parcel = new Parcel ( { entries : args . file , packageManager , defaultConfig : { ... defaultConfig , filePath : ( await packageManager . resolve ( "@parcel/config-default" , __filename ) ) . resolved } , patchConsole : false , ... ( await normalizeOptions ( { isServe : true } ) ) } ) ; let { unsubscribe } = await parcel . watch ( ( err ) => { if ( err ) { throw err ; } } ) ; let isExiting ; const exit = async ( ) => { if ( isExiting ) return ; isExiting = true ; await unsubscribe ( ) ; process . exit ( ) ; } ; if ( process . stdin . isTTY ) { process . stdin . setRawMode && process . stdin . setRawMode ( true ) ; require ( "readline" ) . emitKeypressEvents ( process . stdin ) ; process . stdin . on ( "keypress" , async ( char , key ) => { if ( key . ctrl && key . name === "c" ) { await exit ( ) ; } } ) ; } process . on ( "SIGINT" , exit ) ; process . on ( "SIGTERM" , exit ) ; } }