未验证 提交 f340c454 编写于 作者: B beatles-chameleon 提交者: GitHub

Merge pull request #177 from didi/0.4.x-dev

0.4.x dev
......@@ -31,7 +31,7 @@
"main": "src/index.js",
"name": "chameleon-tool-utils",
"scripts": {
"cover": "istanbul cover --report lcov node_modules/mocha/bin/_mocha -- -R spec --recursive",
"cover": "istanbul cover --report lcov node_modules/mocha/bin/_mocha -- test/*.test.js test/**/*.test.js",
"eslint": "eslint ./src",
"test": "mocha --recursive --reporter spec",
"break-test": "./node_modules/.bin/mocha --inspect-brk --recursive --reporter spec"
......
......@@ -530,8 +530,12 @@ _.getBuildinComponents = function (cmlType, context) {
if (cacheBuildIn[cmlType]) {
return cacheBuildIn[cmlType];
}
let packageFilePath = path.join(context, 'node_modules', builtinNpmName, 'package.json');
let result = _.getOnePackageComponents(builtinNpmName, packageFilePath, cmlType, context);
let newNpmName = builtinNpmName;
if (_.isCli() && cml.extPlatformPlugin && cml.extPlatformPlugin[cmlType]) {
newNpmName = cml.extPlatformPlugin[cmlType].builtinUINpmName || newNpmName;
}
let packageFilePath = path.join(context, 'node_modules', newNpmName, 'package.json');
let result = _.getOnePackageComponents(newNpmName, packageFilePath, cmlType, context);
let compileTagMap = {};
// 内置组件的componet name需要特殊处理,并且挂在cml上给模板编译做处理
result.forEach(item => {
......@@ -858,13 +862,10 @@ _.findPolymorphicComponent = function(interfacePath, content, cmlType) {
function find(interfacePath, content, cmlType) {
let parts = _.splitParts({content});
let include = null;
let include = [];
for (let i = 0;i < parts.customBlocks.length;i++) {
if (parts.customBlocks[i].type === 'include') {
if (include) {
throw new Error(`file just allow has only one <include></include>: ${interfacePath}`)
}
include = parts.customBlocks[i];
include.push(parts.customBlocks[i]);
}
}
let targetScript = null;
......@@ -890,13 +891,14 @@ _.findPolymorphicComponent = function(interfacePath, content, cmlType) {
return sameNamePath;
}
// include中查找
if (include && include.attrs && include.attrs.src) {
let includeFilePath = _.resolveSync(interfacePath, include.attrs.src);
if (!_.isFile) {
for (let i = include.length - 1; i >= 0; i--) {
let item = include[i];
let includeFilePath = _.resolveSync(interfacePath, item.attrs.src);
if (!_.isFile(includeFilePath)) {
throw new Error(`${includeFilePath} is not a file in : ${interfacePath}`);
}
let newContent = fs.readFileSync(includeFilePath, {encoding: 'utf-8'});
return find(includeFilePath, newContent, cmlType);
return find(includeFilePath, newContent, cmlType);
}
}
......@@ -974,26 +976,6 @@ _.npmComponentRefPath = function (componentAbsolutePath, context) {
}
// 已经弃用了 因为在handleComponentUrl 已经返回正确的相对路径
// 将json文件中usingComponents中的组件引用路径从绝对路径改为相对路径,export导出模式要求相对路径
// 如果是绝对路径 导出的组件只能放到项目根目录下,最后生成json文件的时候修改
_.convertToRelativeRef = function (jsonFilePath, jsonObject) {
// if (jsonFilePath[0] !== '/') {
// jsonFilePath = '/' + jsonFilePath;
// }
let components = jsonObject.usingComponents;
if (components) {
Object.keys(components).forEach(key => {
let absoluteRef = components[key];
// plugin:// 开头不处理
if (absoluteRef.indexOf('plugin://') !== 0) {
let relativePath = _.handleRelativePath(jsonFilePath, absoluteRef);
components[key] = relativePath;
}
})
}
}
/**
* @param {String} sourcePath 源文件地址 绝对路径
* @param {String} targetPath 目标文件地址 绝对路径
......
......@@ -433,22 +433,6 @@ describe('index.js', function () {
})
it(`convertToRelativeRef`, function () {
global.cml = {};
_.setCli(true);
cml.event = new EventEmitter();
cml.config = require('./testlib/cli/config.js');
cml.utils = require('../src/index.js');
cml.projectRoot = path.join(__dirname, 'testlib/demo-project');
cml.config.merge({
cmlComponents: ['cml-ui']
})
let result = _.findComponent(__dirname, 'wx');
expect(result).to.equal(false);
})
it('getDevServerPath', function() {
process.env.HOME = __dirname;
let devpath = cml.utils.getDevServerPath();
......
......@@ -2,8 +2,7 @@
// 设置静态资源的线上路径
const publicPath = '//www.static.chameleon.com/cml';
// 设置api请求前缀
const apiPrefix = 'https://api.chameleon.com';
const apiPrefix = 'https://api.chameleon.com';
cml.config.merge({
templateLang: 'cml',
templateType: 'html',
......
......@@ -5,12 +5,16 @@ const CleanWebpackPlugin = require('clean-webpack-plugin')
var path = require('path');
module.exports = function (config, options) {
let { type, root } = options;
let { type, root, externals } = options;
let outputPath = options.outputPath || path.resolve(root, `dist/export/${type}`);
Object.keys(externals).forEach(key => {
externals[key] = `require('${externals[key]}')`;
})
return merge(config, {
output: {
path: outputPath
},
externals,
plugins: [
new CleanWebpackPlugin(['./*'], {root: outputPath, verbose: false})
]
......
......@@ -11,7 +11,8 @@ module.exports = function(options) {
let {
media,
root,
mode = 'production'
mode = 'production',
externals
} = options;
......@@ -153,6 +154,9 @@ module.exports = function(options) {
]
}
if (externals) {
exportConfig.externals = externals;
}
return merge.smart(getWeexCommonConfig(options), exportConfig)
}
......@@ -8,13 +8,13 @@ const resolve = require('resolve');
module.exports = function(options) {
let {type, media} = options;
let npmName = cml.config.get().extPlatform[type];
// let PlatformPlugin = require(path.join(cml.projectRoot, 'node_modules', npmName)); // eslint-disable-line
let PlatformPlugin = require(resolve.sync(npmName, { basedir: cml.projectRoot }));
// 用户端扩展插件
let platformPlugin = new PlatformPlugin({
cmlType: type,
media
});
cml.extPlatformPlugin[type] = platformPlugin;
let extendConfig = {
entry: {
app: path.join(cml.projectRoot, 'src/app/app.cml')
......
......@@ -521,7 +521,8 @@ let babelNpm = [
'webpack-check-plugin',
'webpack-liveload-middleware',
'chameleon-weex-vue-loader',
'babel-plugin-chameleon-import'
'babel-plugin-chameleon-import',
'mvvm-interface-parser'
];
exports.getBabelPath = function () {
......
......@@ -18,7 +18,6 @@ cml.cli = cli;
cml.log = log;
cml.event = new EventEmitter();
cml.utils.setCli(true); // 标识当前在chameleon-cli环境中
// cml.platform = ['wx', 'weex', 'web']; // cml 当前支持的所有平台 决定打包的执行顺序web端放到最后
cml.logLevel = argv.log || 'none'; // 日志输入等级 none debug
cml.log.setLogLevel(cml.logLevel);
......@@ -35,5 +34,5 @@ if (cml.utils.isFile(configPath)) {
}
// 设置内置组件库名称
cml.utils.setBuiltinNpmName(cml.config.get().builtinNpmName);
cml.extPlatformPlugin = {}; // 扩展端的插件对象
cml.cli.run();
......@@ -3,6 +3,7 @@ const cmlUtils = require('chameleon-tool-utils');
const {getCode} = require('./lib/check.js');
const getInterfaceCode = require('./lib/getInterfaceCode.js');
const getMethodCode = require('./lib/getMethodCode.js');
const path = require('path');
// resolve 用于处理interface中include文件中的引用
module.exports = function({cmlType, media, source, filePath, check }) {
......@@ -37,25 +38,10 @@ module.exports = function({cmlType, media, source, filePath, check }) {
}
// 将对象原型上的方法属性拷贝到对象上 解决...扩展运算符取不到值的问题
const copyProtoPath = path.join(__dirname, './runtime/copyProto.js');
const copyProtoProperty = `
function copyProtoProperty(obj = {}) {
let EXPORT_OBJ = obj;
let EXPORT_PROTO = EXPORT_OBJ.__proto__;
if (EXPORT_PROTO.constructor !== Object) {
Object.getOwnPropertyNames(EXPORT_PROTO).forEach(key => {
if (!/constructor|prototype|length/ig.test(key)) {
// 原型上有自身没有的属性 放到自身上
if (!EXPORT_OBJ.hasOwnProperty(key)) {
EXPORT_OBJ[key] = EXPORT_PROTO[key]
}
}
})
}
return EXPORT_OBJ;
}
copyProtoProperty(exports.default)
var copyProtoProperty = require('${cmlUtils.handleRelativePath(filePath, copyProtoPath)}');
copyProtoProperty(exports.default);
`
result = `
${result}
......
const cmlUtils = require('chameleon-tool-utils');
const fs = require('fs');
/**
* 1 先找到所有interface的定义部分
* 2 校验是否一致 如果多个路径指向同一interface 则合并依赖
*/
module.exports = function({interfacePath, content}) {
let devDeps = [];
let result;
let devDeps = []; // 所有interface上的路径都可能影响获取
function getInterface(filePath, content) {
if (filePath !== interfacePath) {
......@@ -12,70 +16,71 @@ module.exports = function({interfacePath, content}) {
if (!content) {
content = fs.readFileSync(filePath, {encoding: 'utf-8'});
}
let parts = cmlUtils.splitParts({content});
let include = null;
let include = [];
for (let i = 0;i < parts.customBlocks.length;i++) {
if (parts.customBlocks[i].type === 'include') {
if (include) {
throw new Error(`file just allow has only one <include></include>: ${filePath}`)
}
include = parts.customBlocks[i];
include.push(parts.customBlocks[i]);
}
}
let interfaceScript = null;
for (let i = 0;i < parts.script.length;i++) {
if (parts.script[i].cmlType === 'interface') {
interfaceScript = parts.script[i];
if (interfaceScript) {
throw new Error(`multi <script cml-type='interface'></script> has define in : ${filePath}`)
} else {
interfaceScript = parts.script[i];
}
}
}
if (include && interfaceScript) {
throw new Error(`file has <include></include> not allow has <script cml-type='interface'></script>: ${filePath}`)
} else if (include === null && interfaceScript) {
return {
filePath: filePath,
part: interfaceScript
if (interfaceScript) {
if (!result) {
if (interfaceScript.attrs && interfaceScript.attrs.src) {
let newFilePath = cmlUtils.resolveSync(filePath, interfaceScript.attrs.src);
if (!cmlUtils.isFile(newFilePath)) {
throw new Error(`not find file: ${newFilePath}`)
}
devDeps.push(newFilePath);
let newContent = fs.readFileSync(newFilePath, {encoding: 'utf-8'});
result = {
content: newContent,
contentFilePath: newFilePath
};
} else {
result = {
content: interfaceScript.content,
contentFilePath: filePath
};
}
} else {
if (result.contentFilePath !== filePath) {
throw new Error(`multi <script cml-type='interface'></script> has define in : ${filePath} and ${result.filePath}`)
}
}
} else if (include && interfaceScript === null) {
if (!include.attrs.src) {
throw new Error(`not define src attribute: ${filePath}`)
}
include.forEach(item => {
if (!item.attrs.src) {
throw new Error(`not define include src attribute in : ${filePath}`)
}
let newFilePath = cmlUtils.resolveSync(filePath, include.attrs.src);
let newFilePath = cmlUtils.resolveSync(filePath, item.attrs.src);
if (!cmlUtils.isFile(newFilePath)) {
throw new Error(`not find file: ${newFilePath}`)
}
// 递归include的文件
return getInterface(newFilePath);
}
return null;
getInterface(newFilePath);
})
}
let result = getInterface(interfacePath, content);
getInterface(interfacePath, content);
if (result) {
let {part, filePath} = result;
// script 有src属性的
if (part.attrs && part.attrs.src) {
let newFilePath = cmlUtils.resolveSync(filePath, part.attrs.src);
if (!cmlUtils.isFile(newFilePath)) {
throw new Error(`not find file: ${newFilePath}`)
}
devDeps.push(newFilePath);
let newContent = fs.readFileSync(newFilePath, {encoding: 'utf-8'});
return {
content: newContent,
devDeps,
contentFilePath: newFilePath
};
} else {
return {
content: result.part.content,
devDeps,
contentFilePath: result.filePath
};
}
return {
content: result.content,
devDeps,
contentFilePath: result.contentFilePath
};
} else {
throw new Error(`not find <script cml-type='interface'></script> in ${interfacePath}`)
}
......
const cmlUtils = require('chameleon-tool-utils');
const fs = require('fs');
module.exports = function({interfacePath, content}) {
let devDeps = [];
function getInterface(filePath, content) {
if (filePath !== interfacePath) {
devDeps.push(filePath);
}
if (!content) {
content = fs.readFileSync(filePath, {encoding: 'utf-8'});
}
let parts = cmlUtils.splitParts({content});
let include = null;
for (let i = 0;i < parts.customBlocks.length;i++) {
if (parts.customBlocks[i].type === 'include') {
if (include) {
throw new Error(`file just allow has only one <include></include>: ${filePath}`)
}
include = parts.customBlocks[i];
}
}
let interfaceScript = null;
for (let i = 0;i < parts.script.length;i++) {
if (parts.script[i].cmlType === 'interface') {
interfaceScript = parts.script[i];
}
}
if (include && interfaceScript) {
throw new Error(`file has <include></include> not allow has <script cml-type='interface'></script>: ${filePath}`)
} else if (include === null && interfaceScript) {
return {
filePath: filePath,
part: interfaceScript
}
} else if (include && interfaceScript === null) {
if (!include.attrs.src) {
throw new Error(`not define src attribute: ${filePath}`)
}
let newFilePath = cmlUtils.resolveSync(filePath, include.attrs.src);
if (!cmlUtils.isFile(newFilePath)) {
throw new Error(`not find file: ${newFilePath}`)
}
// 递归include的文件
return getInterface(newFilePath);
}
return null;
}
let result = getInterface(interfacePath, content);
if (result) {
let {part, filePath} = result;
// script 有src属性的
if (part.attrs && part.attrs.src) {
let newFilePath = cmlUtils.resolveSync(filePath, part.attrs.src);
if (!cmlUtils.isFile(newFilePath)) {
throw new Error(`not find file: ${newFilePath}`)
}
devDeps.push(newFilePath);
let newContent = fs.readFileSync(newFilePath, {encoding: 'utf-8'});
return {
content: newContent,
devDeps,
contentFilePath: newFilePath
};
} else {
return {
content: result.part.content,
devDeps,
contentFilePath: result.filePath
};
}
} else {
throw new Error(`not find <script cml-type='interface'></script> in ${interfacePath}`)
}
}
......@@ -13,13 +13,10 @@ module.exports = function({interfacePath, content, cmlType}) {
}
let parts = cmlUtils.splitParts({content});
let include = null;
let include = [];
for (let i = 0;i < parts.customBlocks.length;i++) {
if (parts.customBlocks[i].type === 'include') {
if (include) {
throw new Error(`file just allow has only one <include></include>: ${filePath}`)
}
include = parts.customBlocks[i];
include.push(parts.customBlocks[i]);
}
}
let methodScript = null;
......@@ -36,21 +33,21 @@ module.exports = function({interfacePath, content, cmlType}) {
}
}
if (include) {
if (!include.attrs.src) {
throw new Error(`not define src attribute: ${filePath}`)
}
let newFilePath = cmlUtils.resolveSync(filePath, include.attrs.src);
if (!cmlUtils.isFile(newFilePath)) {
throw new Error(`not find file: ${newFilePath}`)
for (let i = include.length - 1; i >= 0; i--) {
let item = include[i];
if (item) {
if (!item.attrs.src) {
throw new Error(`not define include src attribute: ${filePath}`)
}
let newFilePath = cmlUtils.resolveSync(filePath, item.attrs.src);
if (!cmlUtils.isFile(newFilePath)) {
throw new Error(`not find file: ${newFilePath}`)
}
let newContent = fs.readFileSync(newFilePath, {encoding: 'utf-8'})
return getMethod(newFilePath, newContent);
}
let newContent = fs.readFileSync(newFilePath, {encoding: 'utf-8'})
return getMethod(newFilePath, newContent);
}
return null;
}
......
const cmlUtils = require('chameleon-tool-utils');
const fs = require('fs');
const {resolveRequire} = require('./resolveRequire.js');
module.exports = function({interfacePath, content, cmlType}) {
let devDeps = [];
function getMethod(filePath, content) {
if (filePath !== interfacePath) {
devDeps.push(filePath);
}
let parts = cmlUtils.splitParts({content});
let include = null;
for (let i = 0;i < parts.customBlocks.length;i++) {
if (parts.customBlocks[i].type === 'include') {
if (include) {
throw new Error(`file just allow has only one <include></include>: ${filePath}`)
}
include = parts.customBlocks[i];
}
}
let methodScript = null;
for (let i = 0;i < parts.script.length;i++) {
if (~parts.script[i].cmlType.split(',').indexOf(cmlType)) {
methodScript = parts.script[i];
}
}
if (methodScript) {
return {
filePath,
part: methodScript
}
}
if (include) {
if (!include.attrs.src) {
throw new Error(`not define src attribute: ${filePath}`)
}
let newFilePath = cmlUtils.resolveSync(filePath, include.attrs.src);
if (!cmlUtils.isFile(newFilePath)) {
throw new Error(`not find file: ${newFilePath}`)
}
let newContent = fs.readFileSync(newFilePath, {encoding: 'utf-8'})
return getMethod(newFilePath, newContent);
}
return null;
}
function getRawContent() {
let result = getMethod(interfacePath, content);
if (result) {
let {part, filePath} = result;
// script 有src属性的
if (part.attrs && part.attrs.src) {
let newFilePath = cmlUtils.resolveSync(filePath, part.attrs.src);
if (!cmlUtils.isFile(newFilePath)) {
throw new Error(`not find file: ${newFilePath}`)
}
devDeps.push(newFilePath);
let newContent = fs.readFileSync(newFilePath, {encoding: 'utf-8'});
return {
content: newContent,
devDeps,
contentFilePath: newFilePath
};
} else {
return {
content: result.part.content,
devDeps,
contentFilePath: result.filePath
};
}
} else {
throw new Error(`not find <script cml-type='${cmlType}'></script> in ${interfacePath}`)
}
}
let {content: newContent, contentFilePath} = getRawContent();
// 需要对原有content中的所有引用路径做解析 解析为绝对路径。
return {
content: resolveRequire({content: newContent, oldFilePath: contentFilePath, newFilePath: interfacePath}),
devDeps,
contentFilePath
}
}
module.exports = function copyProtoProperty(obj) {
var EXPORT_OBJ = obj || {};
var EXPORT_PROTO = Object.getPrototypeOf(EXPORT_OBJ);
if (EXPORT_PROTO.constructor !== Object) {
Object.getOwnPropertyNames(EXPORT_PROTO).forEach(function(key) {
if (!/constructor|prototype|length/ig.test(key)) {
// 原型上有自身没有的属性 放到自身上
if (!EXPORT_OBJ.hasOwnProperty(key)) {
EXPORT_OBJ[key] = EXPORT_PROTO[key]
}
}
})
}
return EXPORT_OBJ;
}
const _ = require('../runtime/copyProto.js');
const expect = require('chai').expect;
class A {
fun1() {
console.log('fun1')
}
}
describe('mvvm-interface-parser/getMethodCode', function() {
it('copyProto.js', function() {
var obj = new A();
_(obj);
expect(obj.hasOwnProperty('fun1'))
})
})
......@@ -23,6 +23,65 @@ describe('mvvm-interface-parser/getInterfaceCode', function() {
let contentPath = path.join(__dirname, './lib/components/thirdinterface.js')
expect(result1.contentFilePath).to.be.equal(contentPath)
expect(!!~result1.devDeps.indexOf(contentPath)).to.be.equal(true)
console.log(result1)
})
it('getInterfaceCode not has interface', function() {
const interfacePath = path.join(__dirname, './lib/components/third/third.interface');
const content = fs.readFileSync(interfacePath, {encoding: 'utf-8'});
try {
getInterfaceCode({interfacePath, content});
} catch (e) {
expect(!!~e.message.indexOf(`not find <script cml-type='interface'></script>`)).to.be.equal(true)
}
})
it('multi interface', function() {
const interfacePath = path.join(__dirname, './lib/components/third/multi.interface');
const content = fs.readFileSync(interfacePath, {encoding: 'utf-8'});
try {
getInterfaceCode({interfacePath, content});
} catch (e) {
expect(!!~e.message.indexOf(`multi <script cml-type='interface'></script>`)).to.be.equal(true)
}
})
it('not has src interface', function() {
const interfacePath = path.join(__dirname, './lib/components/third/not.interface');
const content = fs.readFileSync(interfacePath, {encoding: 'utf-8'});
try {
getInterfaceCode({interfacePath, content});
} catch (e) {
expect(!!~e.message.indexOf(`not find file: `)).to.be.equal(true)
}
})
it('mutli interface', function() {
const interfacePath = path.join(__dirname, './lib/components/third/double.interface');
const content = fs.readFileSync(interfacePath, {encoding: 'utf-8'});
try {
getInterfaceCode({interfacePath, content});
} catch (e) {
expect(!!~e.message.indexOf(`multi <script cml-type='interface'></script> has define in `)).to.be.equal(true)
}
})
it('include src error', function() {
const interfacePath = path.join(__dirname, './lib/components/third/include1.interface');
const content = fs.readFileSync(interfacePath, {encoding: 'utf-8'});
try {
getInterfaceCode({interfacePath, content});
} catch (e) {
expect(!!~e.message.indexOf(`not define include src attribute in`)).to.be.equal(true)
}
})
it('include src not file', function() {
const interfacePath = path.join(__dirname, './lib/components/third/include2.interface');
const content = fs.readFileSync(interfacePath, {encoding: 'utf-8'});
try {
getInterfaceCode({interfacePath, content});
} catch (e) {
expect(!!~e.message.indexOf(`not find file:`)).to.be.equal(true)
}
})
})
......@@ -3,12 +3,11 @@ const expect = require('chai').expect;
const getMethodCode = require('../lib/getMethodCode.js');
const path = require('path');
const fs = require('fs');
const cmlUtils = require('chameleon-tool-utils')
describe('mvvm-interface-parser/getMethodCode', function() {
it('getMethodCode', function() {
const interfacePath = path.join(__dirname, './lib/components/second/second.interface');
const content = fs.readFileSync(interfacePath, {encoding: 'utf-8'})
let result1 = getMethodCode({interfacePath, content, cmlType: 'web', resolve: cmlUtils.resolveSync});
let result1 = getMethodCode({interfacePath, content, cmlType: 'web'});
let firstInterfacePath = path.join(__dirname, './lib/components/first/first.interface');
expect(result1.contentFilePath).to.be.equal(firstInterfacePath)
expect(!!~result1.devDeps.indexOf(firstInterfacePath)).to.be.equal(true)
......@@ -18,11 +17,51 @@ describe('mvvm-interface-parser/getMethodCode', function() {
it('getMethodCode src', function() {
const interfacePath = path.join(__dirname, './lib/components/third.interface');
const content = fs.readFileSync(interfacePath, {encoding: 'utf-8'})
let result1 = getMethodCode({interfacePath, content, cmlType: 'weex', resolve: cmlUtils.resolveSync});
let result1 = getMethodCode({interfacePath, content, cmlType: 'weex'});
let contentPath = path.join(__dirname, './lib/components/thirdmethod.js');
expect(result1.contentFilePath).to.be.equal(contentPath)
expect(!!~result1.devDeps.indexOf(contentPath)).to.be.equal(true)
expect(!!~result1.content.indexOf('thirdmethods')).to.be.equal(true);
})
it('getMethodCode include not src', function() {
const interfacePath = path.join(__dirname, './lib/components/methodinclude.interface');
const content = fs.readFileSync(interfacePath, {encoding: 'utf-8'});
try {
getMethodCode({interfacePath, content, cmlType: 'weex'});
} catch (e) {
expect(!!~e.message.indexOf(`not define include src attribute:`)).to.be.equal(true)
}
})
it('getMethodCode include src error', function() {
const interfacePath = path.join(__dirname, './lib/components/methodsrcerror.interface');
const content = fs.readFileSync(interfacePath, {encoding: 'utf-8'});
try {
getMethodCode({interfacePath, content, cmlType: 'weex'});
} catch (e) {
expect(!!~e.message.indexOf(`not find file:`)).to.be.equal(true)
}
})
it('getMethodCode not find', function() {
const interfacePath = path.join(__dirname, './lib/components/third.interface');
const content = fs.readFileSync(interfacePath, {encoding: 'utf-8'});
try {
getMethodCode({interfacePath, content, cmlType: 'demo'});
} catch (e) {
expect(!!~e.message.indexOf(`not find <script cml-type=`)).to.be.equal(true)
}
})
it('getMethodCode script src not find', function() {
const interfacePath = path.join(__dirname, './lib/components/partsrcerror.interface');
const content = fs.readFileSync(interfacePath, {encoding: 'utf-8'});
try {
getMethodCode({interfacePath, content, cmlType: 'weex'});
} catch (e) {
expect(!!~e.message.indexOf(`not find file`)).to.be.equal(true)
}
})
})
<include src="../../sdf.interfaces"></include>
\ No newline at end of file
<script cml-type="weex" src="../../sdf.js"></script>
\ No newline at end of file
<include src="../third.interface"></include>
<script cml-type="interface"></script>
\ No newline at end of file
<include src="../../sdf.interface">
</include>
\ No newline at end of file
<script cml-type="interface"></script>
<script cml-type="interface"></script>
\ No newline at end of file
<script cml-type="interface" src="../thild.interface"></script>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册