@wulechuan/gulp-classical-task-cycle

0.3.0 • Public • Published

Wulechuan's Tool for Creating Classical Task Cycles for Gulp 4

Multilingual Editions of this Article

NPM Page

Package Name

@wulechuan/gulp-classical-task-cycle

Author

wulechuan (南昌吴乐川)

Introduction

Organize gulp tasks as task cycles. And these cycles should run in parallel. Can also build so-called high order tasks, upon multiple task cycles.

Usage

Example of the createATaskCycle Method

// Import this tool.
const {
    createATaskCycle,
} = require('@wulechuan/gulp-classical-task-cycle')


// Import a gulp pipe tool. Could be gulp-stylus, gulp-sass, etc.
const gulpConvertMarkdownToHTML = require('@wulechuan/gulp-markdown-to-html')


const path = require('path')
const joinPathPOSIX = path.posix.join


// Build a task cycle.
const taskCycleForMarkdownConversions = createATaskCycle({
    descriptionOfInputsOfCoreTask,

    sourceGlobs: {
        rootFolderPath: 'documents/ref',
        // relativeGlobsSharedWithOtherTaskCycles: [],
        relativeGlobsSpecificallyForThisTaskCycle: [ '**/*.md' ],
        extraSourceGlobsToWatch: [ 'config/markdown-conversion-options.js' ],
    },

    outputFiles: {
        rootFolderPath: 'dist/documents/htmls',
        forBatchOutputFiles: {
            relativeGlobsOfAllPossibleOutputs: [ '**/*.html' ],
        },
    },

    compressions: {
        shouldNotOutputCompressedVersion: true,
    },

    firstPipeForProcessingSources: gulpConvertMarkdownToHTML,
})


// Export this task cycle.
module.exports = taskCycleForMarkdownConversions

Example of the create3HighOrderTasksUponMultipleTaskCycles Method

// Import this tool.
const {
    create3HighOrderTasksUponMultipleTaskCycles
} = require('@wulechuan/gulp-classical-task-cycle')


// See the previous example.
const taskCycleForMarkdownConversions = require(
    '../task-cycles/markdown-conversion/to-build-htmls.js'
)


// Assume the task cycle below exists.
const taskCycleForCopyingIllustrates = require(
    '../task-cycles/markdown-conversion/to-copy-illustrates.js'
)


module.exports = create3HighOrderTasksUponMultipleTaskCycles({
    taskCyclesInPallarel: [
        taskCycleForMarkdownConversions,
        taskCycleForCopyingIllustrates,
    ],

    beforeBuildingEveryThingOnce: function() {
        console.log(`\nConverting all markdown files into HTML files`)
    },
})

APIs

TODOS

  • options.sourceGlobs.extraSourceGlobsToWatch

    Members of above array are not relative paths to options.sourceGlobs.rootFolderPath, so as gulp.src process those memebers, I'm not sure what kind of output sub paths would be in the gulp.dest.

License

WTFPL

NOTE:

I'm not an expert about license types. So I temporarily use WTFPL. But I guess this type of license might conflict with the ones used by those npm packages I'm utilizing.

Package Sidebar

Install

npm i @wulechuan/gulp-classical-task-cycle

Weekly Downloads

2

Version

0.3.0

License

WTFPL

Unpacked Size

32 kB

Total Files

7

Last publish

Collaborators

  • wulechuan