anchor.diff:  // All rights reserved. Use of this source code is governed by a BSD-style
   // license that can be found in the LICENSE file.
   
  -import 'dart:async';
   import 'dart:convert';
   import 'dart:io';
   
  
positive.code: 
  final NumberFormat _NF = new NumberFormat.decimalPattern();
  
  void main() {
    defineTask('init', taskFunction: init);
    defineTask('packages', taskFunction: packages, depends: ['init']);
    defineTask('sdk', taskFunction: populateSdk, depends: ['init']);
  
    defineTask('analyze', taskFunction: analyze, depends: ['packages']);
    defineTask('compile', taskFunction: compile, depends: ['packages', 'sdk']);
  
    defineTask('archive', taskFunction : archive,
               depends : ['compile', 'mode-notest']);
    defineTask('release', taskFunction : release,
               depends : ['compile', 'mode-notest']);
  
    defineTask('mode-test', taskFunction: (c) => changeMode(c, true));
    defineTask('mode-notest', taskFunction: (c) => changeMode(c, false));
  
    defineTask('clean', taskFunction: clean);
  
    startGrinder();
  }
  
  void runCommandSync(GrinderContext context, String command, {String cwd}) {
    context.log(command);
  
    var result = Process.runSync(
        '/bin/sh', ['-c', command], workingDirectory: cwd);
  
    if (result.stdout.isNotEmpty) {
      context.log(result.stdout);
    }
    if (result.stderr.isNotEmpty) {
      context.log(result.stderr);
    }
  
    if (result.exitCode > 0) {
      context.fail("exit code ${result.exitCode}");
    }
  }
  
  String getCommandOutput(String command) {
    var result = Process.runSync('/bin/sh', ['-c', command]);
    return result.stdout.trim();
  }
  
  void init(GrinderContext context) {
    // check to make sure we can locate the SDK
    if (sdkDir == null) {
      context.fail("Unable to locate the Dart SDK\n"
  
negative.code:       files.add(name);
      } else {
        files.add("${name}/");
        _createDirectoryListings(entity);
      }
    };
  
    joinFile(dir, ['.files']).writeAsStringSync(JSON.encode(files));
  }
  
  void _printSize(GrinderContext context, File file) {
    int sizeKb = file.lengthSync() ~/ 1024;
    context.log('${file.path} is ${_NF.format(sizeKb)}k');
  }
  
  void _runCommandSync(GrinderContext context, String command, {String cwd}) {
    context.log(command);
  
    var result = Process.runSync(
        '/bin/sh', ['-c', command], workingDirectory: cwd);
  
    if (result.stdout.isNotEmpty) {
      context.log(result.stdout);
    }
    if (result.stderr.isNotEmpty) {
      context.log(result.stderr);
    }
  
    if (result.exitCode > 0) {
      context.fail("exit code ${result.exitCode}");
    }
  }
  
  String _getCommandOutput(String command) {
    return Process.runSync('/bin/sh', ['-c', command]).stdout.trim();
  }
  