npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

gulpfile.ts

v0.0.2

Published

Make a beautiful class-based gulpfiles with Typescript and Gulpfile.ts

Downloads

27

Readme

Make a beautiful class-based gulpfiles with Typescript and Gulpfile.ts

Allows to create a gulp files in classes, each method of which can be a gulp task.

Simple Usage

  1. Install module:

    npm install --save gulpfile.ts

  2. Install required tsd dependencies:

    tsd install --save gulp

  3. Create a gulpfile.ts and describe your tasks

       
    import {Gulpclass, Task} from "gulpfile.ts/Annotations";
    import * as gulp from "gulp";
       
    let del: any = require('del'); // you probably want to define a classes that does not have type definition this way
       
    @Gulpclass()
    export class Gulpfile {
       
        @Task()
        clean(cb: Function) {
            return del(['./dist/**'], cb);
        }
       
        @Task()
        copyFiles() {
            return gulp.src(['./README.md'])
                .pipe(gulp.dest('./dist'));
        }
       
        @Task('copy-source-files') // you can specify custom task name if you need
        copySourceFiles() {
            return gulp.src(['./src/**.js'])
                .pipe(gulp.dest('./dist/src'));
        }
       
        @SequenceTask() // this special annotation using "run-sequence" module to run returned tasks in sequence
        build() {
            return ['copyFiles', 'copy-source-files'];
        }
       
        @Task()
        default() { // because this task has "default" name it will be run as default gulp task
            return ['build'];
        }
       
    }
               
  4. How to run

    The way you run gulp depend of your tsconfig configuration. If you are not using "outDir" in the tsconfig then you probably don't need to do anything - since you are outputting .js code right to the same directory as your gulpfile.ts you will have gulpfile.js right in the same directory, so you can run gulp as you usually do.

    But if you are using "outDir" in your tsconfig, you need to do some extra stuff. Lets say you have specified "build/" as "outDir" in tsconfig. There are two options what you can do:

    • create gulpfile.js and put there require('build/gulpfile')
    • or run gulp in cmd with extra parameters: gulp --gulpfile build/gulpfile.js --cwd .

    First option is preferred because most probably it will be annoying for you to run gulp every time you need to run some task.

Caveats

Its important to understand that you will not able to run your gulp tasks until you compile your gulpfile.ts file. This means that if compiling is a part of your gulp process you will not be able to use it, because there are no gulpfile.js compiled from gulpfile.ts file.

Samples

This project itself using gulpfile.ts. Take a look on it as an example.