Skip to content

Commit

Permalink
2.5.4-dev2
Browse files Browse the repository at this point in the history
* Added some belt and suspenders checks to verify dependency is readable by skeleton
* install-check.js runs from bower to ensure dependency is automatically configured
  • Loading branch information
atomicpages committed Sep 3, 2016
1 parent 042b57b commit 613e129
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 3 deletions.
5 changes: 4 additions & 1 deletion .bowerrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
{
"directory": "dependencies"
"directory": "dependencies",
"scripts": {
"postinstall": "node bin/install/install-check.js"
}
}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ skeleton.*
skeleton_template.css
*.html
dependencies/
.idea/
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ Changelog
### 2.5.4
* Adding `normalize.scss` as a dependency
* Merged master in development for version bump
* Added scripts to check and automagically fix import paths

### 2.5.3
* Comment cleanup
Expand Down
63 changes: 63 additions & 0 deletions bin/install/install-check.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/**
* A simple script to determine where normalize.scss lives. We look for two cases:
* 1. my_bower/skeleton-sass/dependencies/normalize.scss
* 2. my_bower/normalize.scss
* Why is this needed? Sass provides no means for us to reluctantly import
* files meaning we can't use `!optional`
* There are ways to circumvent this by creating a new ruby module for Sass,
* but that doesn't port over to other compilers like libsass or phpsass.
*
* What this script does:
* This script validates the existence of normalize.scss either in skeleton sass
* or in a parent bower folder. This script will find a replace the instances where
* normalize.scss is imported in skeleton sass so you're ready to use skeleton
* out of the box.
*
* Note: normalize.scss is assumed to be in a parent bower directory. This script only
* fixes the import reference if `bower install` is run within skeleton sass.
*/

const fs = require('fs');
const path = require('path');

const MODULE_NAME = "skeleton-sass";
const SEARCH_MODULE = "normalize.scss";
const SKELETON_DEPS_DIRNAME = "dependencies";

(function () {
'use strict';

let segments = __dirname.split(path.sep);

let basePath = segments.slice(0, segments.indexOf(MODULE_NAME)).join(path.sep);
let bowerPath = basePath + path.join(path.sep, SEARCH_MODULE, path.sep);
let internalPath = basePath + path.join(path.sep, MODULE_NAME, SKELETON_DEPS_DIRNAME, SEARCH_MODULE, path.sep);
let normalizeImportFile = basePath + path.join(path.sep, MODULE_NAME, 'skeleton', 'themes', 'fresh', '_vars.scss');

fs.access(bowerPath, fs.F_OK, (bowerError) => {
if(bowerError) {
console.log(bowerPath + ' not found, checking ' + MODULE_NAME + ' dependencies');
fs.access(internalPath, fs.R_OK, (internalDepsError) => {
if(internalDepsError) {
console.error('Missing core dependency for Skeleton Sass: ' + SEARCH_MODULE);
} else {
fs.readFile(normalizeImportFile, 'utf-8', (err, data) => {
if(err) {
throw err;
}

let result = data.replace(/@import.+normalize\.scss.+;/, '@import' +
' "../../../dependencies/normalize.scss/sass/normalize";');

fs.writeFile(normalizeImportFile, result, 'utf-8', (fwErr) => {
if(fwErr) {
throw fwErr;
}
});
});
}
});
}
});

}());
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "skeleton-sass",
"version": "2.5.4",
"version": "2.5.4-dev2",
"author": "Dennis Thompson",
"homepage": "http://atomicpages.github.io/skeleton-sass/",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion skeleton/themes/fresh/_vars.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// stored in the marrow folder, but to also create project-level
// variables.

@import "../../../dependencies/normalize.scss/sass/normalize";
@import "../../../../normalize.scss/sass/normalize";
@import "marrow/mixins";
// @import "my_folder/_foo.scss"; // import dependencies from a custom folder
// @import "bourbon"; // install bourbon in this directory and uncomment this line to enable bourbon, for example
Expand Down

0 comments on commit 613e129

Please sign in to comment.