warmup method

void warmup({
  1. bool background = false,
})

Prepare the project so it can be run. This essentially means that we run pub get however if the project hasn't been initialised then we initialise the project as well. if background is set to true then we run the build as a background process. background defaults to false.

Implementation

void warmup({bool background = false}) {
  _lock.withLock(() {
    try {
      if (background) {
        // we run the clean in the background
        // by running another copy of dcli.
        print('DCli warmup started in the background.');
        '${DCliPaths().dcliName} '
                '-v=${join(Directory.systemTemp.path, 'dcli.warmup.log')}'
                ' warmup $pathToProjectRoot'
            .start(detached: true, runInShell: true);
      } else {
        // print(orange('Running pub get...'));
        _pubget();
      }
    } on PubGetException {
      print(red("\ndcli warmup failed due to the 'pub get' call failing."));
    }
  }, waiting: 'Waiting for warmup to complete...');
}