1 Star 0 Fork 0

helloqingbing/ng-cordova

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
gulpfile.js 3.29 KB
一键复制 编辑 原始数据 按行查看 历史
var gulp = require('gulp'),
buildConfig = require('./config/build.config'),
concat = require('gulp-concat'),
argv = require('minimist')(process.argv.slice(2)),
footer = require('gulp-footer'),
header = require('gulp-header'),
jshint = require('gulp-jshint'),
uglify = require('gulp-uglify'),
Server = require('karma').Server,
karmaConf = require('./config/karma.conf.js'),
rename = require('gulp-rename'),
shell = require('gulp-shell'),
prettify = require('gulp-prettify'),
changelog = require('conventional-changelog'),
q = require('q'),
fs = require('fs'),
jscs = require('gulp-jscs');
gulp.task('default', ['build']);
gulp.task('lint', ['jshint', 'jscs']);
gulp.task('build', function () {
gulp.src(buildConfig.mockFiles)
.pipe(concat('ng-cordova-mocks.js'))
.pipe(header(buildConfig.closureStart))
.pipe(footer(buildConfig.closureEnd))
.pipe(header(buildConfig.banner))
.pipe(gulp.dest(buildConfig.dist))
.pipe(uglify())
.pipe(header(buildConfig.banner))
.pipe(rename({
extname: '.min.js'
}))
.pipe(gulp.dest(buildConfig.dist));
return gulp.src(buildConfig.pluginFiles)
.pipe(concat('ng-cordova.js'))
.pipe(header(buildConfig.closureStart))
.pipe(footer(buildConfig.closureEnd))
.pipe(header(buildConfig.banner))
.pipe(gulp.dest(buildConfig.dist))
.pipe(gulp.dest(buildConfig.demo.ngCordova))
.pipe(uglify())
.pipe(header(buildConfig.banner))
.pipe(rename({extname: '.min.js'}))
.pipe(gulp.dest(buildConfig.dist))
.pipe(gulp.dest(buildConfig.demo.ngCordova));
});
gulp.task('changelog', function () {
var version = buildConfig.versionData.version;
var dest = 'CHANGELOG.md';
return makeChangelog(version).then(function (log) {
fs.writeFileSync(dest, log);
});
});
function makeChangelog(version) {
var file = __dirname + '/CHANGELOG.md';
var deferred = q.defer();
changelog({
repository: 'https://github.com/driftyco/ng-cordova',
version: version,
file: file
}, function (err, log) {
if (err) deferred.reject(err);
else deferred.resolve(log);
});
return deferred.promise;
}
gulp.task('karma', function (done) {
karmaConf.singleRun = true;
argv.browsers && (karmaConf.browsers = argv.browsers.trim().split(','));
argv.reporters && (karmaConf.reporters = argv.reporters.trim().split(','));
var server = new Server(karmaConf, done);
server.start();
});
gulp.task('jshint', function () {
return gulp.src('./src/plugins/*.js')
.pipe(jshint())
.pipe(jshint.reporter('jshint-stylish'))
.pipe(jshint.reporter('fail'));
});
gulp.task('jscs', function () {
gulp.src('src/plugins/*.js')
.pipe(jscs({
fix: true,
"requireSpaceAfterKeywords": ['function']
}))
.pipe(gulp.dest('src/plugins/'));
gulp.src('./src/mocks/*.js')
.pipe(jscs({
fix: true,
"requireSpaceAfterKeywords": ['function']
}))
.pipe(gulp.dest('src/mocks/'));
});
gulp.task('karma-watch', function (done) {
console.log(karmaConf);
karmaConf.singleRun = false;
var server = new Server(karmaConf, done);
server.start();
});
gulp.task('watch', ['build'], function () {
gulp.watch(['src/**/*.js', 'test/**/*.js'], ['build']);
});
gulp.task('run-demo', ['watch'], shell.task([
'cd demo && ionic run ios -l -c --target="iPhone (Retina 4-inch)"'
]));
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/helloqingbing/ng-cordova.git
git@gitee.com:helloqingbing/ng-cordova.git
helloqingbing
ng-cordova
ng-cordova
master

搜索帮助