Index: packages/usage/tool/grind.dart |
diff --git a/packages/usage/tool/grind.dart b/packages/usage/tool/grind.dart |
index da63dc2e34f4f7b274b7a8e56bf81f8629975ab4..f1d8121abe7a5b798bbb6bb6fff49d5b028c9880 100644 |
--- a/packages/usage/tool/grind.dart |
+++ b/packages/usage/tool/grind.dart |
@@ -8,40 +8,35 @@ import 'dart:io'; |
import 'package:grinder/grinder.dart'; |
-final Directory BUILD_DIR = new Directory('build'); |
-final Directory BUILD_TEST_DIR = new Directory('build/test'); |
+final Directory _buildExampleDir = new Directory('build/example'); |
-void main(List<String> args) { |
- task('init', init); |
- task('build', build, ['init']); |
- task('clean', clean); |
+main(List<String> args) => grind(args); |
- startGrinder(args); |
-} |
- |
-/// Do any necessary build set up. |
-void init(GrinderContext context) { |
+@Task('Do any necessary build set up') |
+void init() { |
// Verify we're running in the project root. |
if (!getDir('lib').existsSync() || !getFile('pubspec.yaml').existsSync()) { |
context.fail('This script must be run from the project root.'); |
} |
- BUILD_TEST_DIR.createSync(recursive: true); |
+ _buildExampleDir.createSync(recursive: true); |
} |
-void build(GrinderContext context) { |
+@Task() |
+@Depends(init) |
+void build() { |
// Compile `test/web_test.dart` to the `build/test` dir; measure its size. |
- File srcFile = new File('test/web_test.dart'); |
- Dart2js.compile(context, srcFile, outDir: BUILD_TEST_DIR, minify: true); |
- File outFile = joinFile(BUILD_TEST_DIR, ['web_test.dart.js']); |
+ File srcFile = new File('example/example.dart'); |
+ Dart2js.compile(srcFile, outDir: _buildExampleDir, minify: true); |
+ File outFile = joinFile(_buildExampleDir, ['example.dart.js']); |
context.log('${outFile.path} compiled to ${_printSize(outFile)}'); |
} |
-/// Delete all generated artifacts. |
-void clean(GrinderContext context) { |
+@Task('Delete all generated artifacts') |
+void clean() { |
// Delete the build/ dir. |
- deleteEntity(BUILD_DIR, context); |
+ delete(buildDir); |
} |
String _printSize(File file) => '${(file.lengthSync() + 1023) ~/ 1024}k'; |