当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript task.Task类代码示例

本文整理汇总了TypeScript中@ts-task/task.Task的典型用法代码示例。如果您正苦于以下问题:TypeScript Task类的具体用法?TypeScript Task怎么用?TypeScript Task使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Task类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: generate

    generate (helpers: unknown) {
        const self = this;
        const tasks: Task<unknown, NodeJS.ErrnoException | UnknownError>[] = [];

        if (self.generatorSettings.copyAssets) {
            tasks.push(self.copyAssets());
        }

        // TODO: Remove the files settings, probably walk the dir for .tpl files
        for (let i = 0; i < self.generatorSettings.files.length; i++) {
            // Create the object in charge of rendering the html
            const renderObject = new HtmlWriterFile({
                inputFile: self.generatorSettings.files[i] + '.tpl',
                outputFile: self.generatorSettings.outputDir + '/' + self.generatorSettings.files[i] + '.html',
                renderer: self.renderer
            });

            // ...
            renderObject.setHelpers(helpers);

            // Generate the html
            tasks.push(renderObject.render());
        }

        return Task.all(tasks);
    }
开发者ID:hrajchert,项目名称:mddoc,代码行数:26,代码来源:custom-generator.ts

示例2: generate

    generate () {
        const self = this;
        const tasks: ReturnType<typeof writeFileCreateDir>[] = [];

        self.metadata.renderedFragments = {};

        // For each markdown, create the html fragment
        for (const mdTemplate in self.metadata.jsonml) {
            try {
                const tree = markdown.toHTMLTree(self.metadata.jsonml[mdTemplate]);
                const html = markdown.renderJsonML(tree);

                const outputFilename = self.generatorSettings.outputDir + '/' + mdTemplate + '.html';
                // mhmhmh TODO: This is sooo hardcoded
                self.metadata.renderedFragments[mdTemplate] = 'fragment/' + mdTemplate + '.html';

                tasks.push(writeFileCreateDir(outputFilename, html));

            } catch (e) {
                // TODO: Catch this better
                console.log(red('Problem with ') + mdTemplate);
                throw e;
            }
        }

        return Task.all(tasks);
    }
开发者ID:hrajchert,项目名称:mddoc,代码行数:27,代码来源:html-fragment-generator.ts

示例3: render

 render () {
     const self = this;
     return Task.resolve(this)
         .map(({inputFile, helpers}) => this.renderer.render(inputFile, {mddoc: helpers}))
         .chain(html => writeFileCreateDir(self.outputFile, html))
         .map(tap(_ => console.log(green('We wrote ') + grey(self.outputFile))));
 }
开发者ID:hrajchert,项目名称:mddoc,代码行数:7,代码来源:custom-generator.ts

示例4: mkdir

 .catch(err => {
     if (err.code === 'ENOENT') {
         return mkdir(path);
     } else {
         return Task.reject(err);
     }
 });
开发者ID:hrajchert,项目名称:mddoc,代码行数:7,代码来源:write-file-create-dir.ts

示例5: taskReducer

 const loop = (index: number) => (curr: A): Task<A, E | UnknownError> => {
     if (index >= items.length) {
         return Task.resolve(curr);
     } else {
         return taskReducer(curr, items[index])
             .chain(loop(index + 1));
     }
 };
开发者ID:hrajchert,项目名称:mddoc,代码行数:8,代码来源:task-reduce.ts

示例6: function

 return function (stat: fs.Stats) {
     // If its not a directory, resolve it on the spot with the name of the file
     if (!stat.isDirectory()) {
         return Task.resolve([filename]);
     }
     // If it is, resolve it once its subdirectory is resolved
     else {
         return doWalkDir(filename, options);
     }
 };
开发者ID:hrajchert,项目名称:mddoc,代码行数:10,代码来源:walk-dir.ts

示例7: nextStep

export function sequence<E1> (steps: Step<E1>[]): Task<void, E1> {
    // clone the steps
    const newSteps = [...steps] as [Step<any>];
    // Remove the next step from the array
    const nextStep = newSteps.shift();
    // If there are any left, resolve inmediatly
    if (!nextStep) {
        return Task.resolve(void 0);
    } else {
        // If there is a step invoke it
        return nextStep().chain(
            () => sequence(newSteps)
        );
    }
}
开发者ID:hrajchert,项目名称:mddoc,代码行数:15,代码来源:sequence.ts

示例8:

export function traverseDictionary<T, E> (objOfTasks: Dictionary<Task<T, E>>): Task<Dictionary<T>, UnknownError | E> {
    // Create an array of task with a tuple containing the key and the value
    const tasks =
        Object.keys(objOfTasks)
            .map(key => objOfTasks[key]
                        .map(value => ({key, value}))
            );
    // Wait until all tasks are resolved
    return Task.all(tasks)
                // And transform the array back into an object
                .map(pairs => {
                    const ans: Dictionary<T> = {};
                    pairs.forEach(({key, value}) => ans[key] = value);
                    return ans;
                });
}
开发者ID:hrajchert,项目名称:mddoc,代码行数:16,代码来源:traverse-dictionary.ts

示例9:

        .chain(function (files) {
            const promises: ReturnType<typeof copyFile>[] = [];

            for (let i = 0; i < files.length; i++) {
                const m = files[i].match(matchRe);
                if (m) {
                    const inputFilename = files[i];
                    const outputFilename = dst + '/' + files[i].substr(dirNameLength + 1);
                    // console.log(inputFilename.grey + " => ".green + outputFilename.grey);

                    // Copy the file
                    promises.push(copyFile(inputFilename, outputFilename));
                }
            }
            return Task.all(promises);
        });
开发者ID:hrajchert,项目名称:mddoc,代码行数:16,代码来源:copy-dir.ts


注:本文中的@ts-task/task.Task类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。