-
-
Notifications
You must be signed in to change notification settings - Fork 98
Expand file tree
/
Copy pathPatchesPackagesJson.php
More file actions
30 lines (23 loc) · 911 Bytes
/
PatchesPackagesJson.php
File metadata and controls
30 lines (23 loc) · 911 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<?php
namespace Native\Electron\Traits;
trait PatchesPackagesJson
{
protected function setAppNameAndVersion($developmentMode = false): string
{
$packageJsonPath = __DIR__.'/../../resources/js/package.json';
$packageJson = json_decode(file_get_contents($packageJsonPath), true);
$name = str(config('app.name'))->slug();
/*
* Suffix the app name with '-dev' if it's a development build
* this way, when the developer test his freshly built app,
* configs, migrations won't be mixed up with the production app
*/
if ($developmentMode) {
$name .= '-dev';
}
$packageJson['name'] = $name;
$packageJson['version'] = config('nativephp.version');
file_put_contents($packageJsonPath, json_encode($packageJson, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
return $name;
}
}