-
-
Save adam-singer/5498146 to your computer and use it in GitHub Desktop.
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
library hop_runner; | |
import 'dart:async'; | |
import 'dart:io'; | |
import 'package:hop/hop.dart'; | |
import 'package:hop/hop_tasks.dart'; | |
void main() { | |
final String out = "out"; | |
final String entryPointDir = "web"; | |
final String entryPoint = "webui_chained_hop"; | |
Task dwc = createWebuiCompilerTask("$entryPointDir/$entryPoint.html",output:out); | |
addTask('webui', dwc); | |
Task d2js = createDart2JsTask(["$out/$entryPoint.html_bootstrap.dart"], liveTypeAnalysis: true, rejectDeprecatedFeatures: true); | |
addTask('dart2js', d2js); | |
addTask('app2js',dwc.chain("webui").and("dart2js", d2js)); | |
runHop(); | |
} | |
Task createWebuiCompilerTask(String entryPoint,{String output:"web/out"}){ | |
final entryPointFile = new File(entryPoint); | |
final packageDir = new Directory('packages'); | |
assert(packageDir.existsSync()); | |
assert(entryPointFile.existsSync() && entryPoint.endsWith(".html")); | |
final args = ["--package-root=${packageDir.path}/", | |
"packages/web_ui/dwc.dart", | |
"--out", | |
"$output/", | |
"$entryPoint" | |
]; | |
return new Task.async((TaskContext context){ | |
return _dwc(context, output, entryPoint).whenComplete((){ | |
context.info("completed"); | |
}); | |
}); | |
} | |
Future<bool> _dwc(TaskContext ctx, String output, String entryPoint){ | |
final packageDir = new Directory('packages'); | |
assert(packageDir.existsSync()); | |
final args = ["--package-root=${packageDir.path}/", | |
"packages/web_ui/dwc.dart", | |
"--out", | |
"$output/", | |
"$entryPoint" | |
]; | |
return Process.start("dart", args) | |
.then((process) { | |
return pipeProcess(process, | |
stdOutWriter: ctx.info, | |
stdErrWriter: ctx.severe); | |
}).then((int exitCode){ | |
return exitCode==1; | |
}); | |
} | |
//courtesy https://github.com/kevmoo/hop.dart | |
String _getPlatformBin(String binName) { | |
if(Platform.operatingSystem == 'windows') { | |
return '${binName}.bat'; | |
} else { | |
return binName; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment