warmup method

void warmup({
  1. bool background = false,
  2. bool upgrade = 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.

If upgrade is true then a pub upgrade is ran rather than pub get.

Implementation

void warmup({bool background = false, bool upgrade = 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,
            extensionSearch: false,
          );
        } else {
          // print(orange('Running pub get...'));
          if (upgrade) {
            _pubupgrade();
          } else {
            _pubget();
          }
        }
      } on PubGetException {
        print(red("\ndcli warmup failed due to the 'pub get' call failing."));
      }
    },
    waiting: 'Waiting for warmup to complete...',
  );
}