diff --git a/package.json b/package.json index 65c7598..a062190 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "stylelint": "stylelint scss/**/*.scss", "build:stylelint": "npm run stylelint -- --fix", "build:clean": "rimraf css", - "build:sass": "node-sass --output-style expanded --source-map true scss/nes.scss css/nes.css", + "build:sass": "node-sass --output-style expanded --source-map true --functions scss/functions.js scss/nes.scss css/nes.css", "build:autoprefix": "postcss --use autoprefixer --map false --output css/nes.css css/nes.css", "build:cleancss": "cleancss -o css/nes.min.css css/nes.css", "storybook": "start-storybook -p 6006", @@ -50,6 +50,7 @@ "eslint-config-airbnb-base": "^13.1.0", "eslint-plugin-import": "^2.14.0", "file-loader": "^2.0.0", + "git-rev-sync": "^1.12.0", "husky": "^1.0.0", "lint-staged": "^7.3.0", "node-sass": "^4.9.3", diff --git a/scss/functions.js b/scss/functions.js new file mode 100644 index 0000000..468d277 --- /dev/null +++ b/scss/functions.js @@ -0,0 +1,28 @@ +const git = require('git-rev-sync'); /* eslint-disable-line import/no-extraneous-dependencies */ +const { types } = require('node-sass'); /* eslint-disable-line import/no-extraneous-dependencies */ + +module.exports = { + 'version()': () => { + const packageData = require('../package.json'); /* eslint-disable-line global-require */ + + let buildData = ` + NES.css Framework + Version: ${(git.branch() === 'develop') ? 'development' : `v${packageData.version}`} + `; + + if (git.branch() !== 'master') { + buildData += ` + Build Date: ${(new Date()).toISOString()} + Node Version: ${process.version} + Branch: ${git.branch()} + Commit: ${git.long()}`; + } + + if (process.env.CIRCLECI) { + buildData += ` + Build Number (CircleCI): ${process.env.CIRCLE_BUILD_NUM}`; + } + + return types.String(buildData.replace(/\n/, '').replace(/^ +/gm, ' ')); + }, +}; diff --git a/scss/nes.scss b/scss/nes.scss index 0cb94c0..f1936ab 100644 --- a/scss/nes.scss +++ b/scss/nes.scss @@ -1,8 +1,8 @@ @charset "utf-8"; -/*! -* NES.css v0.0.2(alpha) -*/ +/*****************************************************************************\ +#{version()} +\*****************************************************************************/ @import "base/_index.scss"; @import "utilities/_index.scss";