-
Notifications
You must be signed in to change notification settings - Fork 2.4k
/
gulpfile.js
38 lines (33 loc) · 1.22 KB
/
gulpfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
'use strict';
const gulp = require('gulp'),
minimist = require('minimist'),
rename = require('gulp-rename'),
replace = require('gulp-replace'),
_ = require('lodash');
const flagConfig = {
string: ['port', 'version', 'ngVersion', 'animations'],
boolean: ['dry-run'],
alias: { p: 'port', v: 'version', a: 'ngVersion' },
default: { port: 8000 },
},
flags = minimist(process.argv.slice(2), flagConfig);
/* Docs tasks */
require('./scripts/docs/gulp-tasks')(gulp, flags);
gulp.task('plugin:create', () => {
if (flags.n && flags.n !== '') {
const src = flags.m ? './scripts/templates/wrap-min.tmpl' : './scripts/templates/wrap.tmpl',
pluginName = flags.n,
spaced = pluginName.replace(/(?!^)([A-Z])/g, ' $1'),
kebabCase = _.kebabCase(pluginName);
return gulp
.src(src)
.pipe(replace('{{ PluginName }}', pluginName))
.pipe(replace('{{ Plugin_Name }}', spaced))
.pipe(replace('{{ pluginName }}', _.lowerFirst(pluginName)))
.pipe(replace('{{ plugin-name }}', kebabCase))
.pipe(rename('index.ts'))
.pipe(gulp.dest('./src/@awesome-cordova-plugins/plugins/' + kebabCase));
} else {
console.log('Usage is: gulp plugin:create -n PluginName');
}
});