Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add mechanism for aliases, use for BQ, BL & MF codes #14

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions aliases.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"fr": [
"bl",
"mf"
],
"nl": [
"bq"
]
}
4 changes: 2 additions & 2 deletions dist/sprite/famfamfam-flags.css
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@
background-position: -112px -55px;
}

.famfamfam-flags.fr {
.famfamfam-flags.bl, .famfamfam-flags.mf, .famfamfam-flags.fr {
width: 16px;
height: 11px;
background-position: -112px -66px;
Expand Down Expand Up @@ -993,7 +993,7 @@
background-position: -160px -155px;
}

.famfamfam-flags.nl {
.famfamfam-flags.bq, .famfamfam-flags.nl {
width: 16px;
height: 11px;
background-position: -176px 0px;
Expand Down
2 changes: 1 addition & 1 deletion dist/sprite/famfamfam-flags.min.css

Large diffs are not rendered by default.

Binary file modified dist/sprite/famfamfam-flags.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 18 additions & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,26 @@ qrcode = require('qrcode-terminal'),
gulp = require('gulp'),
imagemin = require('gulp-imagemin'),
rename = require('gulp-rename'),
replace = require('gulp-replace'),
minifyCSS = require('gulp-minify-css'),
spriteBuilder = require( 'node-spritesheet' ).Builder,
notify = require('gulp-notify');

var aliases = {
map: require(path.join(__dirname, 'aliases.json')),

buildRegExp: function() {
return new RegExp('(\\.' + pkg.name + '\\.)(' + Object.keys(aliases.map).join('|') + ')', 'gm');
},

getReplacement: function($0, $prefix, $flag) {
if (!aliases.map[$flag]) {
return $0;
}
return $prefix + aliases.map[$flag].concat($flag).join(', ' + $prefix);
}
};

function displayCowsay (txt, cb) {
console.log('\n\n');
console.log(chalk.magenta(cowsay.say({
Expand Down Expand Up @@ -93,6 +109,8 @@ gulp.task('sprite', ['build_clean'], function (cb) {
});
builder.build(function() {
gulp.src('./dist/sprite/' + pkg.name + '.css')
.pipe(replace(aliases.buildRegExp(), aliases.getReplacement))
.pipe(gulp.dest('./dist/sprite'))
.pipe(minifyCSS({keepSpecialComments: '*'}))
.pipe(rename(pkg.name + '.min.css'))
.pipe(gulp.dest('./dist/sprite'));
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"gulp-minify-css": "~1.2.3",
"gulp-notify": "~2.2",
"gulp-rename": "~1.2",
"gulp-replace": "^0.5.4",
"node-spritesheet": "~0.4",
"qrcode-terminal": "~0.10",
"somebody": "~2.0"
Expand Down