mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-18 19:21:34 +08:00
e2e: make examples build per-platform
This commit is contained in:
110
gulpfile.js
110
gulpfile.js
@ -27,9 +27,12 @@ var traceur = require('gulp-traceur')
|
||||
|
||||
require('./scripts/snapshot/snapshot.task')(gulp, argv, buildConfig)
|
||||
|
||||
gulp.task('default', ['build', 'lib', 'e2e'])
|
||||
gulp.task('default', ['clean'], function() {
|
||||
gulp.run('build')
|
||||
})
|
||||
|
||||
gulp.task('build', ['e2e', 'ionic-js', 'lib', 'sass'])
|
||||
|
||||
gulp.task('build', ['sass', 'ionic-js'])
|
||||
gulp.task('lib', ['ng2', 'fonts', 'dependencies'])
|
||||
|
||||
gulp.task('watch', ['default'], function() {
|
||||
@ -78,36 +81,89 @@ gulp.task('clean', function(done) {
|
||||
del([buildConfig.dist], done)
|
||||
})
|
||||
|
||||
gulp.task('e2e', ['build'], function() {
|
||||
gulp.task('e2e', ['ionic-js', 'sass'], function() {
|
||||
var indexContents = _.template( fs.readFileSync('scripts/e2e/index.template.html') )({
|
||||
buildConfig: buildConfig
|
||||
})
|
||||
});
|
||||
var platformJsTemplate = _.template( fs.readFileSync('scripts/e2e/platform.template.js') )
|
||||
var testTemplate = _.template( fs.readFileSync('scripts/e2e/e2e.template.js') )
|
||||
|
||||
return gulp.src(buildConfig.src.e2e)
|
||||
.pipe(rename(function(file) {
|
||||
file.dirname = file.dirname.replace('/test/', '/')
|
||||
}))
|
||||
.pipe(gulpif(/main.html$/, through2.obj(function(file, enc, next) {
|
||||
var indexClone = _.clone(file)
|
||||
this.push(new VinylFile(_.assign(indexClone, {
|
||||
contents: new Buffer(indexContents),
|
||||
path: file.path.replace(/main.html$/, 'index.html'),
|
||||
})))
|
||||
next(null, file)
|
||||
})))
|
||||
.pipe(gulpif(/.e2e.js$/, through2.obj(function(file, enc, next) {
|
||||
var relativePath = path.dirname(file.path.replace(/^.*?src.components/, ''))
|
||||
var contents = file.contents.toString()
|
||||
contents = testTemplate({
|
||||
contents: contents,
|
||||
buildConfig: buildConfig,
|
||||
relativePath: relativePath
|
||||
var platforms = [
|
||||
'android',
|
||||
'default',
|
||||
'ios',
|
||||
]
|
||||
|
||||
return gulp.src(buildConfig.src.e2eTest)
|
||||
.pipe(through2.obj(function(file, enc, next) {
|
||||
var self = this
|
||||
gulp.src(file.path + '/**/*', {
|
||||
base: file.path
|
||||
})
|
||||
file.contents = new Buffer(contents)
|
||||
next(null, file)
|
||||
})))
|
||||
.pipe(gulpif({ isFile: true }, gulp.dest(buildConfig.dist + '/e2e')))
|
||||
.pipe(gulpif(/main.html$/, processMainHtml()))
|
||||
.on('data', function(file) {
|
||||
if (file.stat && !file.stat.isFile()) return;
|
||||
|
||||
file.path = file.path.replace(/(\\|\/)test/, '')
|
||||
file.base = path.join(__dirname, 'src', 'components');
|
||||
var dirname = path.dirname(file.path)
|
||||
var basename = path.basename(file.path);
|
||||
|
||||
platforms.forEach(function(platform) {
|
||||
var platformDir = dirname + '-' + platform;
|
||||
var platformFilePath = file.path.replace(dirname, platformDir);
|
||||
self.push(new VinylFile({
|
||||
path: platformFilePath,
|
||||
base: file.base,
|
||||
contents: file.contents.slice()
|
||||
}));
|
||||
|
||||
// Add a new platform.js file beside each index.html
|
||||
if (basename === 'index.html') {
|
||||
self.push(new VinylFile({
|
||||
path: platformFilePath.replace(/index.html$/, 'platform.js'),
|
||||
base: file.base,
|
||||
contents: new Buffer(platformJsTemplate({
|
||||
platform: platform
|
||||
}))
|
||||
}))
|
||||
}
|
||||
})
|
||||
})
|
||||
.on('end', next)
|
||||
|
||||
function processMainHtml() {
|
||||
return through2.obj(function(file, enc, next) {
|
||||
this.push(new VinylFile({
|
||||
base: file.base,
|
||||
contents: new Buffer(indexContents),
|
||||
path: file.path.replace(/main.html$/, 'index.html'),
|
||||
}))
|
||||
next(null, file)
|
||||
})
|
||||
}
|
||||
}))
|
||||
.pipe(gulp.dest(buildConfig.dist + '/e2e'));
|
||||
// .pipe(gulpif(/main.html$/, through2.obj(function(file, enc, next) {
|
||||
// var indexClone = _.clone(file)
|
||||
// this.push(new VinylFile(_.assign(indexClone, {
|
||||
// contents: new Buffer(indexContents),
|
||||
// path: file.path.replace(/main.html$/, 'index.html'),
|
||||
// })))
|
||||
// next(null, file)
|
||||
// })))
|
||||
// .pipe(gulpif(/e2e.js$/, through2.obj(function(file, enc, next) {
|
||||
// var relativePath = path.dirname(file.path.replace(/^.*?src.components/, ''))
|
||||
// var contents = file.contents.toString()
|
||||
// contents = testTemplate({
|
||||
// contents: contents,
|
||||
// buildConfig: buildConfig,
|
||||
// relativePath: relativePath
|
||||
// })
|
||||
// file.contents = new Buffer(contents)
|
||||
// next(null, file)
|
||||
// })))
|
||||
// .pipe(gulpif({ isFile: true }, gulp.dest(buildConfig.dist + '/e2e')))
|
||||
})
|
||||
|
||||
// Take es6 files from angular2's output, rename to js, and move to dist/lib/
|
||||
|
Reference in New Issue
Block a user