Skip to content

Latest commit

 

History

History
67 lines (47 loc) · 1.94 KB

README.md

File metadata and controls

67 lines (47 loc) · 1.94 KB

gulp-publish-tasks

Common gulp tasks I use to automate publishing of npm packages.

NOTICE

Stability: 2 - UNSTABLE

Tasks

browserify

Build a browser-compatible file from an npm package. Uses Browserify.

argument type description
sourcePath String source js file path
destinationPath String destination file path
[options={}] Object
[options.minify=false] Boolean minify output with minifyify
[options.es5compat=true] Boolean transpile to ES5 with babelify

updateMarkdownTOC

Insert a Table of Contents into a markdown file. Uses the excellent markdown-toc package.

argument type description
markdownPath String Path to the markdown file (e.g. 'README.md'). Path is relative to gulpfile's location.

updateSourceVersion

Updates the source version string in a javascript file. Replacement locations must be tagged with publish-tasks:auto-version comment.

name type description
sourcePath String Path to the source file. Path is relative to gulpfile's location.
newVersion String New semver to be inserted (best to use package.json's version field).

Notice: currently only supports numeric semvers (e.g. 2.3.11).

Usage

In your gulpfile, register the tasks, then use them as usual.

//gulpfile.js
var publishTasks = require('gulp-publish-tasks');
var version = require('package.json').version;
...
gulp.task('update-readme-toc', () => publishTasks.updateMarkdownTOC('README.md'));
gulp.task('update-source-version', () => publishTasks.updateSourceVersion('path/to/source.js', version));
//path/to/source.js
...
/* publish-tasks:auto-version */
MyLibrary.VERSION = '1.0.0'; // ------ will be replaced with version from package.json

TODO

  • unit tests
  • more tasks