mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-28 09:25:50 +08:00
Added definitions for gulp-load-plugins
This commit is contained in:
53
gulp-load-plugins/gulp-load-plugins-tests.ts
Normal file
53
gulp-load-plugins/gulp-load-plugins-tests.ts
Normal file
@@ -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();
|
||||
42
gulp-load-plugins/gulp-load-plugins.d.ts
vendored
Normal file
42
gulp-load-plugins/gulp-load-plugins.d.ts
vendored
Normal file
@@ -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 {
|
||||
}
|
||||
Reference in New Issue
Block a user