Skip to content

Instantly share code, notes, and snippets.

@bsutton
Last active December 22, 2021 04:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bsutton/07a57bf541c7b1804d0c3d438d2d7ae7 to your computer and use it in GitHub Desktop.
Save bsutton/07a57bf541c7b1804d0c3d438d2d7ae7 to your computer and use it in GitHub Desktop.
#! /usr/bin/env dcli
import 'dart:io';
import 'package:dcli/dcli.dart';
void main(List<String> arguments) {
final pubspec = DartProject.fromPath('.').pubSpec;
final isFlutter = pubspec.dependencies.containsKey('flutter');
if (isFlutter) {
if (which('flutter').notfound) {
printerr(red('Add flutter to your PATH and try again.'));
exit(1);
}
startFromArgs(
'flutter',
['pub', ...arguments],
nothrow: true,
progress: Progress.print(),
);
} else {
if (which('dart').notfound) {
printerr(red('Add dart to your PATH and try again.'));
exit(1);
}
DartSdk().runPub(args: arguments, nothrow: true);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment