diff options
Diffstat (limited to 'gulpfile.js')
-rw-r--r-- | gulpfile.js | 134 |
1 files changed, 132 insertions, 2 deletions
diff --git a/gulpfile.js b/gulpfile.js index 679c3efe..ab729bed 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -192,7 +192,7 @@ gulp.task('optimize', function (cb) { .replace(/\s?\/>/g, ' />') .replace(/\n\s*<(line|circle|path|polyline|rect)/g, "\n <$1") .replace(/polyline points="([0-9.]+)\s([0-9.]+)\s([0-9.]+)\s([0-9.]+)"/g, 'line x1="$1" y1="$2" x2="$3" y2="$4"') - .replace(/a([0-9.]+)\s([0-9.]+)\s([0-9.]+)\s?([0-1])\s?([0-1])\s?(-?[0-9.]+)\s?(-?[0-9.]+)/g, 'a$1 $2 $3 $4 $5 $6 $7') + .replace(/a\s?([0-9.]+)\s([0-9.]+)\s([0-9.]+)\s?([0-1])\s?([0-1])\s?(-?[0-9.]+)\s?(-?[0-9.]+)/g, 'a$1 $2 $3 $4 $5 $6 $7') .replace(/\n\n+/g, "\n"); fs.writeFileSync(file, svgFileContent); @@ -202,7 +202,137 @@ gulp.task('optimize', function (cb) { }); }); -gulp.task('build-zip', function(cb) { +gulp.task('changelog-commit', function(cb) { + cp.exec('git status', function(err, ret) { + let newIcons = [], modifiedIcons = [], renamedIcons = []; + + ret.replace(/new file:\s+src\/_icons\/([a-z1-9-]+)\.svg/g, function (m, fileName) { + newIcons.push(fileName); + }); + + ret.replace(/modified:\s+src\/_icons\/([a-z1-9-]+)\.svg/g, function (m, fileName) { + modifiedIcons.push(fileName); + }); + + ret.replace(/renamed:\s+src\/_icons\/([a-z1-9-]+).svg -> src\/_icons\/([a-z1-9-]+).svg/g, function (m, fileNameBefore, fileNameAfter) { + renamedIcons.push([fileNameBefore, fileNameAfter]); + }); + + modifiedIcons = modifiedIcons.filter( function( el ) { + return newIcons.indexOf( el ) < 0; + }); + + if(newIcons.length > 0) { + let str = ''; + str += `${newIcons.length} new icons: `; + + newIcons.forEach(function(icon, i){ + str += `\`${icon}\``; + + if((i + 1) <= newIcons.length - 1) { + str += ', ' + } + }); + + console.log(str); + console.log(''); + } + + if(modifiedIcons.length > 0) { + let str = ''; + str += `Fixed icons: `; + + modifiedIcons.forEach(function(icon, i){ + str += `\`${icon}\``; + + if((i + 1) <= modifiedIcons.length - 1) { + str += ', ' + } + }); + + console.log(str); + console.log(''); + } + + if(renamedIcons.length > 0) { + console.log(`**Renamed icons: `); + + renamedIcons.forEach(function(icon, i){ + console.log(`- \`${icon[0]}\` renamed to \`${icon[1]}\``); + }); + } + + cb(); + }); +}); + +gulp.task('changelog-diff', function(cb) { + const version = p.version; + cp.exec(`git diff v${version} HEAD --name-status`, function(err, ret) { + + let newIcons = [], modifiedIcons = [], renamedIcons = []; + + ret.replace(/A\s+src\/_icons\/([a-z1-9-]+)\.svg/g, function (m, fileName) { + newIcons.push(fileName); + }); + + ret.replace(/M\s+src\/_icons\/([a-z1-9-]+)\.svg/g, function (m, fileName) { + modifiedIcons.push(fileName); + }); + + ret.replace(/R[0-9]+\s+src\/_icons\/([a-z1-9-]+)\.svg\s+src\/_icons\/([a-z1-9-]+).svg/g, function (m, fileNameBefore, fileNameAfter) { + renamedIcons.push([fileNameBefore, fileNameAfter]); + }); + + modifiedIcons = modifiedIcons.filter( function( el ) { + return newIcons.indexOf( el ) < 0; + }); + + if(newIcons.length > 0) { + let str = ''; + str += `${newIcons.length} new icons: `; + + newIcons.forEach(function(icon, i){ + str += `\`${icon}\``; + + if((i + 1) <= newIcons.length - 1) { + str += ', ' + } + }); + + console.log(str); + console.log(''); + } + + if(modifiedIcons.length > 0) { + let str = ''; + str += `Fixed icons: `; + + modifiedIcons.forEach(function(icon, i){ + str += `\`${icon}\``; + + if((i + 1) <= modifiedIcons.length - 1) { + str += ', ' + } + }); + + console.log(str); + console.log(''); + } + + if(renamedIcons.length > 0) { + console.log(`**Renamed icons: `); + + renamedIcons.forEach(function(icon, i){ + console.log(`- \`${icon[0]}\` renamed to \`${icon[1]}\``); + }); + } + + cb(); + }); +}); + +gulp.task('build-zip', function() { const version = p.version; return gulp.src('{icons/**/*,icons-png/**/*,tabler-sprite.svg,tabler-sprite-nostroke.svg}') |