lib/index.js
function start() {
    console.log(
      'Using ts-node version',
      tsNodeVersion + ', typescript version',
      tsVersion
    )
    var cmd = nodeArgs.concat(wrapper, script, scriptArgs)
    var childHookPath = compiler.getChildHookPath()
    cmd = ['-r', childHookPath].concat(cmd)
    log.debug('Starting child process %s', cmd.join(' '))
    child = fork(cmd[0], cmd.slice(1), {
      cwd: process.cwd(),
      env: process.env
    })
    starting = false
    var compileReqWatcher = filewatcher({ forcePolling: opts.poll })
    var currentCompilePath
    fs.writeFileSync(compiler.getCompileReqFilePath(), '')
    compileReqWatcher.add(compiler.getCompileReqFilePath())
    compileReqWatcher.on('change', function(file) {
      fs.readFile(file, 'utf-8', function(err, data) {
        if (err) {
          log.error('Error reading compile request file', err)
          return
        }
        var split = data.split('\n')
        var compile = split[0]
        var compiledPath = split[1]
        if (currentCompilePath == compiledPath) return
        currentCompilePath = compiledPath
        // console.log('compileReqWatcher file change', compile);
        if (compiledPath) {
          compiler.compile({
            compile: compile,
            compiledPath: compiledPath
          })
        }
      })
    })
    child.on('message', function(message) {
      if (!message.compiledPath || currentCompilePath === message.compiledPath)
        return
      currentCompilePath = message.compiledPath
      compiler.compile(message)
    })

    child.on('exit', function(code) {
      log.debug('Child exited with code %s', code)
      if (!child) return
      if (!child.respawn) process.exit(code)
      child = undefined
    })

    if (cfg.respawn) {
      child.respawn = true
    }

    if (compiler.tsConfigPath) {
      watcher.add(compiler.tsConfigPath)
    }

    // Listen for `required` messages and watch the required file.
    ipc.on(child, 'required', function(m) {
      var isIgnored =
        cfg.ignore.some(isPrefixOf(m.required)) ||
        cfg.ignore.some(isRegExpMatch(m.required))

      if (!isIgnored && (cfg.deps === -1 || getLevel(m.required) <= cfg.deps)) {
        watcher.add(m.required)
      }
    })

    // Upon errors, display a notification and tell the child to exit.
    ipc.on(child, 'error', function(m) {
      notify(m.error, m.message, 'error')
      stop(m.willTerminate)
    })
    compiler.writeReadyFile()
  }
function start() {
    console.log(
      'Using ts-node version',
      tsNodeVersion + ', typescript version',
      tsVersion
    )
    var cmd = nodeArgs.concat(wrapper, script, scriptArgs)
    var childHookPath = compiler.getChildHookPath()
    cmd = ['-r', childHookPath].concat(cmd)
    log.debug('Starting child process %s', cmd.join(' '))
    child = fork(cmd[0], cmd.slice(1), {
      cwd: process.cwd(),
      env: process.env
    })
    starting = false
    var compileReqWatcher = filewatcher({ forcePolling: opts.poll })
    var currentCompilePath
    fs.writeFileSync(compiler.getCompileReqFilePath(), '')
    compileReqWatcher.add(compiler.getCompileReqFilePath())
    compileReqWatcher.on('change', function(file) {
      fs.readFile(file, 'utf-8', function(err, data) {
        if (err) {
          log.error('Error reading compile request file', err)
          return
        }
        var split = data.split('\n')
        var compile = split[0]
        var compiledPath = split[1]
        if (currentCompilePath == compiledPath) return
        currentCompilePath = compiledPath
        // console.log('compileReqWatcher file change', compile);
        if (compiledPath) {
          compiler.compile({
            compile: compile,
            compiledPath: compiledPath
          })
        }
      })
    })
    child.on('message', function(message) {
      if (!message.compiledPath || currentCompilePath === message.compiledPath)
        return
      currentCompilePath = message.compiledPath
      compiler.compile(message)
    })

    child.on('exit', function(code) {
      log.debug('Child exited with code %s', code)
      if (!child) return
      if (!child.respawn) process.exit(code)
      child = undefined
    })

    if (cfg.respawn) {
      child.respawn = true
    }

    if (compiler.tsConfigPath) {
      watcher.add(compiler.tsConfigPath)
    }

    // Listen for `required` messages and watch the required file.
    ipc.on(child, 'required', function(m) {
      var isIgnored =
        cfg.ignore.some(isPrefixOf(m.required)) ||
        cfg.ignore.some(isRegExpMatch(m.required))

      if (!isIgnored && (cfg.deps === -1 || getLevel(m.required) <= cfg.deps)) {
        watcher.add(m.required)
      }
    })

    // Upon errors, display a notification and tell the child to exit.
    ipc.on(child, 'error', function(m) {
      notify(m.error, m.message, 'error')
      stop(m.willTerminate)
    })
    compiler.writeReadyFile()
  }
function start ( ) { console . log ( 'Using ts-node version' , tsNodeVersion + ', typescript version' , tsVersion ) var cmd = nodeArgs . concat ( wrapper , script , scriptArgs ) var childHookPath = compiler . getChildHookPath ( ) cmd = [ '-r' , childHookPath ] . concat ( cmd ) log . debug ( 'Starting child process %s' , cmd . join ( ' ' ) ) child = fork ( cmd [ 0 ] , cmd . slice ( 1 ) , { cwd : process . cwd ( ) , env : process . env } ) starting = false var compileReqWatcher = filewatcher ( { forcePolling : opts . poll } ) var currentCompilePath fs . writeFileSync ( compiler . getCompileReqFilePath ( ) , '' ) compileReqWatcher . add ( compiler . getCompileReqFilePath ( ) ) compileReqWatcher . on ( 'change' , function ( file ) { fs . readFile ( file , 'utf-8' , function ( err , data ) { if ( err ) { log . error ( 'Error reading compile request file' , err ) return } var split = data . split ( '\n' ) var compile = split [ 0 ] var compiledPath = split [ 1 ] if ( currentCompilePath == compiledPath ) return currentCompilePath = compiledPath // console.log('compileReqWatcher file change', compile); if ( compiledPath ) { compiler . compile ( { compile : compile , compiledPath : compiledPath } ) } } ) } ) child . on ( 'message' , function ( message ) { if ( ! message . compiledPath || currentCompilePath === message . compiledPath ) return currentCompilePath = message . compiledPath compiler . compile ( message ) } ) child . on ( 'exit' , function ( code ) { log . debug ( 'Child exited with code %s' , code ) if ( ! child ) return if ( ! child . respawn ) process . exit ( code ) child = undefined } ) if ( cfg . respawn ) { child . respawn = true } if ( compiler . tsConfigPath ) { watcher . add ( compiler . tsConfigPath ) } // Listen for `required` messages and watch the required file. ipc . on ( child , 'required' , function ( m ) { var isIgnored = cfg . ignore . some ( isPrefixOf ( m . required ) ) || cfg . ignore . some ( isRegExpMatch ( m . required ) ) if ( ! isIgnored && ( cfg . deps === - 1 || getLevel ( m . required ) <= cfg . deps ) ) { watcher . add ( m . required ) } } ) // Upon errors, display a notification and tell the child to exit. ipc . on ( child , 'error' , function ( m ) { notify ( m . error , m . message , 'error' ) stop ( m . willTerminate ) } ) compiler . writeReadyFile ( ) }
Run the wrapped script.
Run the wrapped script .