Skip to content

Commit 888c493

Browse files
committed
Make directory for nested paths
1 parent 515e427 commit 888c493

12 files changed

+46
-41
lines changed

src/Commands/EraseCommand.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,7 @@ public function handle()
6969
unset($generated['created']);
7070
unset($generated['updated']);
7171

72-
$this->files->put(
73-
'.blueprint',
74-
$blueprint->dump($generated)
75-
);
72+
$this->files->put('.blueprint', $blueprint->dump($generated));
7673
}
7774

7875
/**

src/Commands/TraceCommand.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,7 @@ public function handle()
7070

7171
$cache['models'] = $definitions;
7272

73-
$this->files->put(
74-
'.blueprint',
75-
$blueprint->dump($cache)
76-
);
73+
$this->files->put('.blueprint', $blueprint->dump($cache));
7774

7875
$this->info('Traced ' . count($definitions) . ' ' . Str::plural('model', count($definitions)));
7976
}

src/Generators/ControllerGenerator.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,14 @@ public function output(array $tree): array
3939
/** @var \Blueprint\Models\Controller $controller */
4040
foreach ($tree['controllers'] as $controller) {
4141
$this->addImport($controller, 'Illuminate\\Http\\Request');
42+
4243
$path = $this->getPath($controller);
43-
$this->files->put(
44-
$path,
45-
$this->populateStub($stub, $controller)
46-
);
44+
45+
if (!$this->files->exists(dirname($path))) {
46+
$this->files->makeDirectory(dirname($path), 0755, true);
47+
}
48+
49+
$this->files->put($path, $this->populateStub($stub, $controller));
4750

4851
$output['created'][] = $path;
4952
}

src/Generators/ModelGenerator.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ public function output(array $tree): array
2727
/** @var \Blueprint\Models\Model $model */
2828
foreach ($tree['models'] as $model) {
2929
$path = $this->getPath($model);
30+
31+
if (!$this->files->exists(dirname($path))) {
32+
$this->files->makeDirectory(dirname($path), 0755, true);
33+
}
34+
3035
$this->files->put($path, $this->populateStub($stub, $model));
3136

3237
$output['created'][] = $path;

src/Generators/Statements/EventGenerator.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,13 @@ public function output(array $tree): array
4545
$this->files->makeDirectory(dirname($path), 0755, true);
4646
}
4747

48-
$this->files->put(
49-
$path,
50-
$this->populateStub($stub, $statement)
51-
);
48+
$this->files->put($path, $this->populateStub($stub, $statement));
5249

5350
$output['created'][] = $path;
5451
}
5552
}
5653
}
54+
5755
return $output;
5856
}
5957

src/Generators/Statements/FormRequestGenerator.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,7 @@ public function output(array $tree): array
5252
$this->files->makeDirectory(dirname($path), 0755, true);
5353
}
5454

55-
$this->files->put(
56-
$path,
57-
$this->populateStub($stub, $name, $context, $statement, $controller)
58-
);
55+
$this->files->put($path, $this->populateStub($stub, $name, $context, $statement, $controller));
5956

6057
$output['created'][] = $path;
6158
}

src/Generators/Statements/JobGenerator.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,13 @@ public function output(array $tree): array
4141
$this->files->makeDirectory(dirname($path), 0755, true);
4242
}
4343

44-
$this->files->put(
45-
$path,
46-
$this->populateStub($stub, $statement)
47-
);
44+
$this->files->put($path, $this->populateStub($stub, $statement));
4845

4946
$output['created'][] = $path;
5047
}
5148
}
5249
}
50+
5351
return $output;
5452
}
5553

src/Generators/Statements/MailGenerator.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,13 @@ public function output(array $tree): array
4141
$this->files->makeDirectory(dirname($path), 0755, true);
4242
}
4343

44-
$this->files->put(
45-
$path,
46-
$this->populateStub($stub, $statement)
47-
);
44+
$this->files->put($path, $this->populateStub($stub, $statement));
4845

4946
$output['created'][] = $path;
5047
}
5148
}
5249
}
50+
5351
return $output;
5452
}
5553

src/Generators/Statements/ViewGenerator.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,13 @@ public function output(array $tree): array
4242
$this->files->makeDirectory(dirname($path), 0755, true);
4343
}
4444

45-
$this->files->put(
46-
$path,
47-
$this->populateStub($stub, $statement)
48-
);
45+
$this->files->put($path, $this->populateStub($stub, $statement));
4946

5047
$output['created'][] = $path;
5148
}
5249
}
5350
}
51+
5452
return $output;
5553
}
5654

src/Generators/TestGenerator.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,7 @@ public function output(array $tree): array
5454
$this->files->makeDirectory(dirname($path), 0755, true);
5555
}
5656

57-
$this->files->put(
58-
$path,
59-
$this->populateStub($stub, $controller)
60-
);
57+
$this->files->put($path, $this->populateStub($stub, $controller));
6158

6259
$output['created'][] = $path;
6360
}

0 commit comments

Comments
 (0)