-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
77 lines (64 loc) · 2.25 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
var gulp = require('gulp');
var Path = require('path');
gulp.task('deploy', function () {
var zip = require('gulp-zip');
var findParentDir = require('find-parent-dir');
var config = {
accessKeyId: "ACCESSKEY",
secretAccessKey: "secretAccessKey"
}
// var s3 = require('gulp-s3-upload')(config);
var dir;
try {
dir = findParentDir.sync(__dirname, '.git');
dir = dir.split('/').pop();
} catch(err) {
console.error('error', err);
}
return gulp.src([ '**' ,'!.*', '!composer.json', '!package.json', '!gulpfile.js', '!node_modules/**' ])
.pipe(zip(dir+'.zip'))
// .pipe(gulp.dest('../')).pipe(s3({
// Bucket: 'bucket-name', // Required
// }, {
// S3 Construcor Options, ie:
// maxRetries: 5
// }));
});
gulp.task('rename', function(){
var replace = require('gulp-replace');
var rename = require("gulp-rename");
// If a name has been passed...
if(process.argv[4] !==undefined){
var fullName = process.argv[4];
var className = fullName.replace(/ /g, '');
var slug = fullName.toLowerCase().replace(/ /g, '-').replace(/---/g, '-');
var hookSlug = fullName.toLowerCase().replace(/ /g, '_');
console.log({fullname:fullName, classname:className, slug: slug, hookslug:hookSlug})
gulp.src(['plugin-name.php'])
.pipe(replace(/My Plugin Name/g, fullName))
.pipe(replace(/plugin_name/g, hookSlug))
.pipe(replace(/PluginName/g, className))
.pipe(replace(/plugin-name/g, slug))
.pipe(rename({
basename:slug}))
.pipe(gulp.dest("./"));
}else{
console.log('I didn\'t get that name...');
console.log(process.argv)
}
});
gulp.task('move', function(){
// If a name has been passed...
if(process.argv[4] !==undefined){
var fullName = process.argv[4];
var className = fullName.replace(/ /g, '');
var slug = fullName.toLowerCase().replace(/ /g, '-').replace(/---/g, '-');
var hookSlug = fullName.toLowerCase().replace(/ /g, '_');
var findParentDir = require('find-parent-dir');
var fs = require('fs');
var fulldir = findParentDir.sync(__dirname, '.git');
var basedir = fulldir.split('/').pop();
var newdir = fulldir.replace(basedir, slug);
fs.rename(fulldir, newdir);
}
})