Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add a bin/grind.dart and a bin/grinder.dart script
- Loading branch information
1 parent
5846e01
commit 0af59d5
Showing
3 changed files
with
60 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// Copyright 2014 Google. All rights reserved. Use of this source code is | ||
// governed by a BSD-style license that can be found in the LICENSE file. | ||
|
||
/** | ||
* Look for `tool/grind.dart` relative to the current directory and run it. | ||
*/ | ||
library grinder.grind; | ||
|
||
import 'grinder.dart' as g; | ||
|
||
void main(List args) => g.runScript('tool/grind.dart', args); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// Copyright 2014 Google. All rights reserved. Use of this source code is | ||
// governed by a BSD-style license that can be found in the LICENSE file. | ||
|
||
/** | ||
* Look for `tool/grinder.dart` relative to the current directory and run it. | ||
*/ | ||
library grinder.grinder; | ||
|
||
import 'dart:io'; | ||
|
||
void main(List args) => runScript('tool/grinder.dart', args); | ||
|
||
void runScript(String script, List args) { | ||
File file = new File(script); | ||
|
||
if (!file.existsSync()) { | ||
print("Error: expected to find a '${script}' script."); | ||
exit(1); | ||
} | ||
|
||
List newArgs = [script]..addAll(args); | ||
_runProcessAsync(Platform.isWindows ? 'dart.exe' : 'dart', newArgs); | ||
} | ||
|
||
void _runProcessAsync(String executable, List<String> arguments) { | ||
Process.start(executable, arguments).then((Process process) { | ||
process.stdout.listen((List<int> data) { | ||
stdout.write(new String.fromCharCodes(data)); | ||
}); | ||
|
||
process.stderr.listen((List<int> data) { | ||
stderr.write(new String.fromCharCodes(data)); | ||
}); | ||
|
||
return process.exitCode.then((int code) { | ||
if (code != 0) exit(code); | ||
}); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters