compile method

void compile({
  1. bool install = false,
  2. bool overwrite = false,
})

Compiles this script and optionally installs it to ~/.dcli/bin

The resulting executable is compiled into the script's directory.

If install is true (default = false) then the resulting executable will be moved into ~/.dcli/bin.

If install is true and overwrite is true (default) it will overwrite any existing exe in ~/.dcli/bin. If install is true and overwrite is false and an exe of the same name already exists in ~/.dcli/bin the install will fail and a MoveException will be thrown.

Implementation

void compile({bool install = false, bool overwrite = false}) {
  Settings().verbose('\nCompiling with pubspec.yaml:\n'
      "${read(pathToPubSpec).toList().join('\n')}\n");

  if (install && isInstalled && !overwrite) {
    throw InvalidArguments(
        'You selected to install the compiled exe however an installed '
        'exe of that name already exists. Use overwrite=true');
  }

  DartSdk().runDartCompiler(this,
      pathToExe: pathToExe, progress: Progress(print, stderr: print));

  if (install) {
    print('');
    print(orange('Installing $pathToExe into $pathToInstalledExe'));
    move(pathToExe, pathToInstalledExe, overwrite: true);
  }
}