Skip to content

Commit

Permalink
fix: wrong path in init
Browse files Browse the repository at this point in the history
  • Loading branch information
vaetas committed Nov 18, 2020
1 parent 2838eef commit 7422b46
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
5 changes: 3 additions & 2 deletions lib/blake.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,14 @@ class Blake {
final runner = CommandRunner<int>('blake', 'Blake Static Site Generator');

Future<int> call(List<String> args) async {
runner.addCommand(InitCommand());

try {
final config = await getConfig();

runner
..addCommand(BuildCommand(config))
..addCommand(ServeCommand(config))
..addCommand(InitCommand());
..addCommand(ServeCommand(config));

return runner.run(args);
} catch (e) {
Expand Down
8 changes: 5 additions & 3 deletions lib/src/commands/init_command.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class InitCommand extends Command<int> {

@override
FutureOr<int> run() async {
final name = argResults.rest.isEmpty ? '' : argResults.rest.first;
final name = argResults.rest.isEmpty ? '.' : argResults.rest.first;

if (name.isEmpty) {
log.info('Initializing project in current directory...');
Expand All @@ -31,8 +31,9 @@ class InitCommand extends Command<int> {
await Directory('$name/content').create();
await Directory('$name/templates').create();
await Directory('$name/static').create();
await Directory('$name/data').create();
} catch (e) {
log.severe('Init failed', e);
log.severe(e);
return 1;
}

Expand All @@ -41,7 +42,8 @@ class InitCommand extends Command<int> {
}

Future<void> _initConfig(String root) async {
final configFile = await File('$root/config.yaml').create(recursive: true);
final configFile = await File('${root.isEmpty ? '$root/' : ''}config.yaml')
.create(recursive: true);
final config = await configFile.readAsString();

if (config.trim().isNotEmpty) {
Expand Down

0 comments on commit 7422b46

Please sign in to comment.