forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added definitions for gulp-load-plugins
- Loading branch information
Joe Skeen
committed
Aug 4, 2015
1 parent
070e3a5
commit 8850b96
Showing
2 changed files
with
95 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/// <reference path="../node/node" /> | ||
/// <reference path="../gulp/gulp" /> | ||
/// <reference path="../gulp-concat/gulp-concat" /> | ||
/// <reference path="gulp-load-plugins" /> | ||
|
||
import gulp = require('gulp'); | ||
import gulpConcat = require('gulp-concat'); | ||
import gulpLoadPlugins = require('gulp-load-plugins'); | ||
|
||
interface GulpPlugins extends IGulpPlugins { | ||
concat: typeof gulpConcat; | ||
} | ||
|
||
var plugins = <GulpPlugins>gulpLoadPlugins({ | ||
pattern: ['gulp-*', 'gulp.*'], | ||
config: 'package.json', | ||
scope: ['dependencies', 'devDependencies', 'peerDependencies'], | ||
replaceString: /^gulp(-|\.)/, | ||
camelize: true, | ||
lazy: true, | ||
rename: {} | ||
}); | ||
plugins = <GulpPlugins>gulpLoadPlugins(); | ||
|
||
gulp.task('taskName', () => { | ||
gulp.src('*.*') | ||
.pipe(plugins.concat('concatenated.js')) | ||
.pipe(gulp.dest('output')); | ||
}); | ||
|
||
/* | ||
* From 0.8.0, you can pass in an object of mappings for renaming plugins. For example, | ||
* imagine you want to load the gulp-ruby-sass plugin, but want to refer to it as just | ||
* sass : | ||
*/ | ||
plugins = <GulpPlugins>gulpLoadPlugins({ | ||
rename: { | ||
'gulp-ruby-sass': 'sass' | ||
} | ||
}); | ||
/* | ||
* gulp-load-plugins comes with npm scope support. The major difference is that scoped | ||
* plugins are accessible through an object on plugins that represents the scope. For | ||
* example, if the plugin is @myco/gulp-test-plugin then you can access the plugin as | ||
* shown in the following example: | ||
*/ | ||
interface GulpPlugins { | ||
myco: { | ||
testPlugin(): NodeJS.ReadWriteStream; | ||
} | ||
} | ||
|
||
plugins.myco.testPlugin(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// Type definitions for gulp-load-plugins | ||
// Project: https://github.com/jackfranklin/gulp-load-plugins | ||
// Definitions by: Joe Skeen <joeskeen@outlook.com> | ||
// Definitions: https://github.com/borisyankov/DefinitelyTyped | ||
|
||
/// <reference path="../node/node.d.ts" /> | ||
|
||
/** Loads in any gulp plugins and attaches them to an object, freeing you up from having to manually require each gulp plugin. */ | ||
declare module 'gulp-load-plugins' { | ||
|
||
interface IOptions { | ||
/** the glob(s) to search for, default ['gulp-*', 'gulp.*'] */ | ||
pattern?: string[]; | ||
/** where to find the plugins, searched up from process.cwd(), default 'package.json' */ | ||
config?: string; | ||
/** which keys in the config to look within, default ['dependencies', 'devDependencies', 'peerDependencies'] */ | ||
scope?: string[]; | ||
/** what to remove from the name of the module when adding it to the context, default /^gulp(-|\.)/ */ | ||
replaceString?: RegExp; | ||
/** if true, transforms hyphenated plugin names to camel case, default true */ | ||
camelize?: boolean; | ||
/** whether the plugins should be lazy loaded on demand, default true */ | ||
lazy?: boolean; | ||
/** a mapping of plugins to rename, the key being the NPM name of the package, and the value being an alias you define */ | ||
rename?: IPluginNameMappings; | ||
} | ||
|
||
interface IPluginNameMappings { | ||
[npmPackageName: string]: string | ||
} | ||
|
||
/** Loads in any gulp plugins and attaches them to an object, freeing you up from having to manually require each gulp plugin. */ | ||
function gulpLoadPlugins(options?: IOptions): IGulpPlugins; | ||
|
||
export = gulpLoadPlugins; | ||
} | ||
|
||
/** | ||
* Extend this interface to use Gulp plugins in your gulpfile.js | ||
*/ | ||
interface IGulpPlugins { | ||
} |