mirror of
https://github.com/cocos/cocos4.git
synced 2026-12-03 01:12:42 +08:00
Merge pull request #1219 from jareguo/master
支持在 engine-extends 中使用 ES6
This commit is contained in:
@@ -210,7 +210,7 @@ function loadUuid (item, callback) {
|
||||
return Object;
|
||||
};
|
||||
|
||||
var tdInfo = CC_JSB ? new cc.deserialize.Details() : (item.deserializeInfo || _tdInfo);
|
||||
var tdInfo = CC_JSB ? new cc.deserialize.Details() : _tdInfo;
|
||||
|
||||
var asset;
|
||||
try {
|
||||
@@ -221,6 +221,7 @@ function loadUuid (item, callback) {
|
||||
});
|
||||
}
|
||||
catch (e) {
|
||||
tdInfo.reset();
|
||||
var err = CC_JSB ? (e + '\n' + e.stack) : e.stack;
|
||||
callback( new Error('Uuid Loader: Deserialize asset [' + item.id + '] failed : ' + err) );
|
||||
return;
|
||||
|
||||
@@ -63,8 +63,6 @@ var AssetLibrary = {
|
||||
* @param {Boolean} options.readMainCache - Default is true. If false, the asset and all its depends assets will reload and create new instances from library.
|
||||
* @param {Boolean} options.writeMainCache - Default is true. If true, the result will cache to AssetLibrary, and MUST be unload by user manually.
|
||||
* @param {Asset} options.existingAsset - load to existing asset, this argument is only available in editor
|
||||
* @param {deserialize.Details} options.deserializeInfo - specified a DeserializeInfo object if you want,
|
||||
* this parameter is only available in editor.
|
||||
* @private
|
||||
*/
|
||||
loadAsset: function (uuid, callback, options) {
|
||||
@@ -77,9 +75,6 @@ var AssetLibrary = {
|
||||
id: uuid,
|
||||
type: 'uuid'
|
||||
};
|
||||
if (options && options.deserializeInfo) {
|
||||
item.deserializeInfo = options.deserializeInfo;
|
||||
}
|
||||
if (options && options.existingAsset) {
|
||||
item.existingAsset = options.existingAsset;
|
||||
}
|
||||
|
||||
+34
-12
@@ -33,26 +33,48 @@ const Gulp = require('gulp');
|
||||
const Fb = require('gulp-fb');
|
||||
const Buffer = require('vinyl-buffer');
|
||||
const HandleErrors = require('../util/handleErrors');
|
||||
const EventStream = require('event-stream');
|
||||
const Es = require('event-stream');
|
||||
|
||||
const Utils = require('./utils');
|
||||
|
||||
exports.build = function (sourceFile, outputFile, callback) {
|
||||
var jsEntryEditorExtends = '../editor/test-utils/engine-extends-entry.js';
|
||||
|
||||
if (Fs.existsSync(jsEntryEditorExtends)) {
|
||||
sourceFile = [sourceFile, jsEntryEditorExtends]
|
||||
}
|
||||
|
||||
Utils.createBundler(sourceFile)
|
||||
exports.build = function (sourceFile, outputFile, sourceFileForExtends, outputFileForExtends, callback) {
|
||||
var engine = Utils.createBundler(sourceFile)
|
||||
.ignore('./bin/modular-cocos2d-cut.js')
|
||||
.bundle()
|
||||
.on('error', HandleErrors.handler)
|
||||
.pipe(HandleErrors())
|
||||
.pipe(Source(Path.basename(outputFile)))
|
||||
.pipe(Buffer())
|
||||
.pipe(Gulp.dest(Path.dirname(outputFile)))
|
||||
.on('end', callback);
|
||||
.pipe(Gulp.dest(Path.dirname(outputFile)));
|
||||
|
||||
if (Fs.existsSync(sourceFileForExtends)) {
|
||||
var Babelify;
|
||||
try {
|
||||
Babelify = require('babelify');
|
||||
} catch (e) {
|
||||
console.error('Please run "npm install babelify".');
|
||||
throw e;
|
||||
}
|
||||
var engineExtends = Utils.createBundler(sourceFileForExtends)
|
||||
.ignore('./bin/modular-cocos2d-cut.js')
|
||||
.transform(Babelify, {
|
||||
presets: ["es2015"],
|
||||
ast: false,
|
||||
highlightCode: false,
|
||||
sourceMaps: true,
|
||||
compact: false
|
||||
})
|
||||
.bundle()
|
||||
.on('error', HandleErrors.handler)
|
||||
.pipe(HandleErrors())
|
||||
.pipe(Source(Path.basename(outputFileForExtends)))
|
||||
.pipe(Buffer())
|
||||
.pipe(Gulp.dest(Path.dirname(outputFileForExtends)));
|
||||
Es.merge(engine, engineExtends).on('end', callback);
|
||||
}
|
||||
else {
|
||||
engine.on('end', callback);
|
||||
}
|
||||
};
|
||||
|
||||
exports.clean = function (list, callback) {
|
||||
@@ -63,7 +85,7 @@ exports.unit = function (outDir, libs, callback) {
|
||||
var title = 'Cocos2d-JS Test Suite';
|
||||
if (Fs.existsSync('./bin/cocos2d-js-extends-for-test.js')) {
|
||||
libs.push('./bin/cocos2d-js-extends-for-test.js');
|
||||
title += ' (Editor Extends Included)'
|
||||
title += ' (Editor Extends Included)';
|
||||
}
|
||||
return Gulp.src('test/qunit/unit/**/*.js', { read: false, base: './' })
|
||||
.pipe(Fb.toFileList())
|
||||
|
||||
+4
-2
@@ -122,10 +122,12 @@ gulp.task('clean-test', function (done) {
|
||||
});
|
||||
|
||||
gulp.task('build-test', ['build-modular-cocos2d', 'clean-test'], function (done) {
|
||||
Test.build('./index.js', './bin/cocos2d-js-for-test.js', done);
|
||||
Test.build('./index.js', './bin/cocos2d-js-for-test.js',
|
||||
'../editor/test-utils/engine-extends-entry.js','./bin/cocos2d-js-extends-for-test.js',
|
||||
done);
|
||||
});
|
||||
|
||||
gulp.task('unit-runner', [], function (done) {
|
||||
gulp.task('unit-runner', ['build-test'], function (done) {
|
||||
Test.unit('./bin', [
|
||||
'./bin/cocos2d-js-for-test.js'
|
||||
], done);
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
module('JSON packer/unpacker');
|
||||
|
||||
(function () {
|
||||
|
||||
if (!TestEditorExtends) {
|
||||
return;
|
||||
}
|
||||
|
||||
var KEY1 = 'amitabha';
|
||||
var JSON1 = {
|
||||
__born__: 1985,
|
||||
|
||||
Reference in New Issue
Block a user