Skip to content

Commit

Permalink
Merge pull request #1812 from roots/option-to-add-font-awesome
Browse files Browse the repository at this point in the history
Add option to add Font Awesome
  • Loading branch information
retlehs authored Jan 17, 2017
2 parents 1826102 + 1f8f24f commit 89b4d1c
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
### 9.0.0-beta.2: TBD
* Add option to add Font Awesome ([#1812](https://github.com/roots/sage/pull/1812))
* Add option to change theme file headers ([#1811](https://github.com/roots/sage/pull/1811))
* Add option to remove Bootstrap ([#1810](https://github.com/roots/sage/pull/1810))
* Remove Font Awesome ([#1809](https://github.com/roots/sage/pull/1809))
Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@
],
"post-create-project-cmd": [
"Roots\\Sage\\PostCreateProject::updateHeaders",
"Roots\\Sage\\PostCreateProject::removeBootstrap"
"Roots\\Sage\\PostCreateProject::removeBootstrap",
"Roots\\Sage\\PostCreateProject::addFontAwesome"
]
}
}
20 changes: 19 additions & 1 deletion src/lib/Sage/PostCreateProject.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ public static function removeBootstrap(Event $event)
if ($io->isInteractive()) {
if ($io->askConfirmation('<info>Remove Bootstrap?</info> [<comment>y,N</comment>]? ', false)) {
file_put_contents('package.json', str_replace(' "bootstrap": "^4.0.0-alpha.6",' . "\n", '', file_get_contents('package.json')));
file_put_contents('assets/styles/main.scss', str_replace('// Import npm dependencies' . "\n", '', file_get_contents('assets/styles/main.scss')));
file_put_contents('assets/styles/main.scss', str_replace('@import "~bootstrap/scss/bootstrap";' . "\n", '', file_get_contents('assets/styles/main.scss')));
file_put_contents('assets/scripts/main.js', str_replace('import \'bootstrap/dist/js/bootstrap\';' . "\n", '', file_get_contents('assets/scripts/main.js')));
file_put_contents('assets/styles/components/_comments.scss', '');
Expand All @@ -52,5 +51,24 @@ public static function removeBootstrap(Event $event)
}
}
}

public static function addFontAwesome(Event $event)
{
$io = $event->getIO();

if ($io->isInteractive()) {
if ($io->askConfirmation('<info>Add Font Awesome?</info> [<comment>y,N</comment>]? ', false)) {
$package = json_decode(file_get_contents('package.json'), true);
$dependencies = $package['dependencies'];
$dependencies = array_merge($dependencies, ['font-awesome' => '^4.7.0']);
$package['dependencies'] = $dependencies;
$package = str_replace(' ', ' ', json_encode($package, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES) . "\n");

$import_dep_str = '// Import npm dependencies' . "\n";
file_put_contents('assets/styles/main.scss', str_replace($import_dep_str, $import_dep_str . '@import "~font-awesome/scss/font-awesome";' . "\n", file_get_contents('assets/styles/main.scss')));
file_put_contents('assets/styles/common/_variables.scss', "\n" . '$fa-font-path: \'~font-awesome/fonts\';' . "\n", FILE_APPEND);
}
}
}
// @codingStandardsIgnoreEnd
}

0 comments on commit 89b4d1c

Please sign in to comment.