1
0
mirror of https://github.com/nostalgic-css/NES.css.git synced 2025-08-19 12:31:21 +02:00

refactor: Move SCSS functions and abstract build data retrieval

I've moved the SCSS functions file into the `scripts` directory where I think it makes a bit more
sense. I've also abstracted most of the functionality from it so I can also use it in
`semantic-release`'s preparation step.
This commit is contained in:
Trezy
2018-12-16 22:48:53 -06:00
parent 81914e66c7
commit 69fb58eccb
5 changed files with 37 additions and 30 deletions

View File

@@ -7,7 +7,7 @@
"stylelint": "stylelint scss/**/*.scss", "stylelint": "stylelint scss/**/*.scss",
"build:stylelint": "npm run stylelint -- --fix", "build:stylelint": "npm run stylelint -- --fix",
"build:clean": "rimraf css", "build:clean": "rimraf css",
"build:sass": "node-sass --output-style expanded --source-map true --functions scss/functions.js scss/nes.scss css/nes.css", "build:sass": "node-sass --output-style expanded --source-map true --functions scripts/scssFunctions.js scss/nes.scss css/nes.css",
"build:autoprefix": "postcss --use autoprefixer --map false --output css/nes.css 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", "build:cleancss": "cleancss -o css/nes.min.css css/nes.css",
"storybook": "start-storybook -p 6006", "storybook": "start-storybook -p 6006",

26
scripts/getBuildData.js Normal file
View File

@@ -0,0 +1,26 @@
const git = require('git-rev-sync'); /* eslint-disable-line import/no-extraneous-dependencies */
module.exports = (isCompiled = false) => {
let buildData = '';
if (git.branch() !== 'master') {
buildData += '\n';
if (isCompiled) {
buildData += `
Build Date: ${(new Date()).toISOString()}
Node Version: ${process.version}`;
}
buildData += `
Branch: ${git.branch()}
Commit: ${git.long()}`;
if (process.env.CIRCLECI) {
buildData += `
Build Number (CircleCI): ${process.env.CIRCLE_BUILD_NUM}`;
}
}
return buildData.replace(/\n/, '').replace(/^ +/gm, ' ');
};

7
scripts/scssFunctions.js Normal file
View File

@@ -0,0 +1,7 @@
const { types } = require('node-sass'); /* eslint-disable-line import/no-extraneous-dependencies */
const getBuildData = require('./getBuildData');
module.exports = {
'build-data()': () => types.String(getBuildData(true)),
};

View File

@@ -1,28 +0,0 @@
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, ' '));
},
};

View File

@@ -1,7 +1,9 @@
@charset "utf-8"; @charset "utf-8";
/*****************************************************************************\ /*****************************************************************************\
#{version()} NES.css Framework
Version: development
#{build-data()}
\*****************************************************************************/ \*****************************************************************************/
@import "base/_index.scss"; @import "base/_index.scss";