Skip to content

Commit 40690e9

Browse files
committed
Improve license comment
Keep the license comment in minified files, add version in the license comment
1 parent fa79cf9 commit 40690e9

File tree

5 files changed

+62
-7
lines changed

5 files changed

+62
-7
lines changed

gulpfile.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ const uglify = require('gulp-uglify');
77
const minifyCss = require('gulp-minify-css');
88
const rename = require('gulp-rename');
99
const zip = require('gulp-zip');
10+
const replace = require('gulp-replace');
1011
const projectVersion = require('./package.json').version;
1112

1213
const SOURCE_PATH = 'src/';
@@ -24,26 +25,28 @@ function cleanBuild() {
2425
function buildScripts() {
2526
// store both minified and unminified scrips to dist
2627
return src(`${SOURCE_PATH}/*.js`)
28+
.pipe(replace(/(\/\*\!\n\s+\*\sToastMaker)/m, '$1 v' + projectVersion)) // add version in license comment
2729
.pipe(babel())
2830
.pipe(dest(DISTRIBUTABLE_PATH))
29-
.pipe(uglify())
31+
.pipe(uglify({ output: { comments: "some" /* to preserve license comment */ } }))
3032
.pipe(rename({ extname: '.min.js' }))
3133
.pipe(dest(DISTRIBUTABLE_PATH));
3234
}
3335

3436
function buildCss() {
3537
// store both minified and unminified css to dist
3638
return src(`${SOURCE_PATH}/*.css`)
39+
.pipe(replace(/(\/\*\!\n\s+\*\sToastMaker)/m, '$1 v' + projectVersion)) // add version in license comment
3740
.pipe(dest(DISTRIBUTABLE_PATH))
38-
.pipe(minifyCss())
41+
.pipe(minifyCss()/* auto preserves license comment */)
3942
.pipe(rename({ extname: '.min.css' }))
4043
.pipe(dest(DISTRIBUTABLE_PATH));
4144
}
4245

4346
function generatePackage() {
44-
// mainly created for ci, so that package can be uploaded to release
45-
// store the package in the build dir and not in the dist
46-
// since dist dir is used in npm publish
47+
// mainly created for ci, so that package can be uploaded to the release page.
48+
// store the package in the build dir & not in the dist
49+
// since dist dir is used in npm publish and we want to only include code & not any zip in npm module.
4750

4851
return src(`${DISTRIBUTABLE_PATH}/**/*`)
4952
.pipe(zip(`toastmaker-v${projectVersion}.zip`))

package-lock.json

Lines changed: 51 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
"gulp-clean": "^0.4.0",
3434
"gulp-minify-css": "^1.2.4",
3535
"gulp-rename": "^2.0.0",
36+
"gulp-replace": "^1.0.0",
3637
"gulp-uglify": "^3.0.2",
3738
"gulp-zip": "^5.0.2",
3839
"jsdom": "16.2.2",

src/toastmaker.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*!
22
* ToastMaker
33
* https://github.com/vivekweb2013/toastmaker
4-
* License: MIT
4+
* @license MIT
55
*/
66
.toastmaker {
77
animation-name: toastEffect;

src/toastmaker.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*!
22
* ToastMaker
33
* https://github.com/vivekweb2013/toastmaker
4-
* License: MIT
4+
* @license MIT
55
*/
66
(function (global, factory) {
77
// UMD(Universal Module Definition) Pattern - https://github.com/umdjs/umd

0 commit comments

Comments
 (0)