Skip to content
Snippets Groups Projects
Commit 82473084 authored by Seth Ladd's avatar Seth Ladd
Browse files

move shared files up to superclass

parent 472099fa
No related branches found
No related tags found
No related merge requests found
......@@ -16,11 +16,9 @@ class HelloWorldGenerator extends Generator {
"A simple hello world command-line application.",
categories: const ['dart', 'helloworld']) {
_addFile('.gitignore', gitIgnoreContents);
_addFile('pubspec.yaml', _pubspec);
_addFile('readme.md', _readme);
_addFile('bin/helloworld.dart', _helloworld);
_addFile('LICENSE', license);
addFile('pubspec.yaml', _pubspec);
addFile('readme.md', _readme);
addFile('bin/helloworld.dart', _helloworld);
setEntrypoint(files.last);
}
......@@ -45,6 +43,4 @@ main() {
}
''';
TemplateFile _addFile(String path, String contents) =>
addFile(new TemplateFile(path, contents));
}
......@@ -17,18 +17,13 @@ class WebAppGenerator extends Generator {
"too much going on.",
categories: const ['dart', 'web']) {
_addFile('.gitignore', gitIgnoreContents);
_addFile('pubspec.yaml', _pubspec);
_addFile('readme.md', _readme);
_addFile('web/styles.css', _styles);
setEntrypoint(_addFile('web/index.html', _index));
_addFile('web/main.dart', _main);
_addFile('LICENSE', license);
addFile('pubspec.yaml', _pubspec);
addFile('readme.md', _readme);
addFile('web/styles.css', _styles);
setEntrypoint(addFile('web/index.html', _index));
addFile('web/main.dart', _main);
}
TemplateFile _addFile(String path, String contents) =>
addFile(new TemplateFile(path, contents));
String get _pubspec => '''
name: {{projectName}}
description: >
......
......@@ -38,7 +38,10 @@ abstract class Generator {
final List<TemplateFile> files = [];
TemplateFile _entrypoint;
Generator(this.id, this.description, {this.categories: const []});
Generator(this.id, this.description, {this.categories: const []}) {
addFile('.gitignore', gitIgnoreContents);
addFile('LICENSE', license);
}
/**
* The entrypoint of the application; the main file for the project, which an
......@@ -49,7 +52,7 @@ abstract class Generator {
/**
* TODO:
*/
TemplateFile addFile(TemplateFile file) {
TemplateFile addTemplateFile(TemplateFile file) {
files.add(file);
return file;
}
......@@ -73,6 +76,9 @@ abstract class Generator {
int numFiles() => files.length;
String toString() => '[${id}: ${description}]';
TemplateFile addFile(String path, String contents) =>
addTemplateFile(new TemplateFile(path, contents));
}
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment