diff --git a/README.md b/README.md index fd37186..da86cde 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,48 @@ [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier) [![Build Status](https://travis-ci.org/lgcavalheiro/gulp-mammoth.svg?branch=main)](https://travis-ci.org/lgcavalheiro/gulp-mammoth) [![Coverage Status](https://coveralls.io/repos/github/lgcavalheiro/gulp-mammoth/badge.svg?branch=main&service=github)](https://coveralls.io/github/lgcavalheiro/gulp-mammoth?branch=main) -## Gulp plugin that converts Word documents to html or markdown files using [mammoth.js](https://github.com/mwilliamson/mammoth.js) +### Gulp plugin that converts Word documents to html or markdown files using [mammoth.js](https://github.com/mwilliamson/mammoth.js) --- -## Project still under construction, more TBD +## Basic usage + +```javascript +const gulp = require("gulp"); +const series = gulp.series; + +const mammoth = require("../src/index"); + +function basicUsage() { + return gulp.src("./data/nonEmpty.docx").pipe(mammoth("html")).pipe(gulp.dest("./results")); +} + +module.exports.default = series(basicUsage); +``` + +## Usage example with gulp-if + +```javascript +const gulp = require("gulp"); +const gulpIf = require("gulp-if"); +const series = gulp.series; + +const mammoth = require("../src/index"); + +function withGulpIf() { + return gulp + .src("./data/*") + .pipe(gulpIf(file => file.basename.toLowerCase().includes("html"), mammoth("html"))) + .pipe(gulpIf(file => file.basename.toLowerCase().includes("markdown"), mammoth("md"))) + .pipe(gulpIf(file => file.basename.toLowerCase().includes("text"), mammoth("txt"))) + .pipe(gulp.dest("./results")); +} + +module.exports.default = series(withGulpIf); +``` + +All usage examples can be found on `example` folder and can be executed with `yarn gulp --gulpfile ./example/name_of_file.gulpfile.js` + +## Running tests + +You can use `yarn test` to run the test suite once, or you can run `yarn gulp` inside the root of the project to activate continuous TDD (it will run the tests every time a file is updated). \ No newline at end of file diff --git a/package.json b/package.json index bbd5f2f..b0499e6 100644 --- a/package.json +++ b/package.json @@ -1,11 +1,10 @@ { "name": "gulp-mammoth", - "version": "0.1.0", + "version": "1.0.0", "description": "Gulp plugin that uses mammoth.js to convert word documents to html or markdown.", "main": "src/index.js", "scripts": { "test": "nyc mocha test/unit/*.test.js", - "tdd": "gulp", "coveralls": "nyc report --reporter=text-lcov | coveralls" }, "keywords": [