@zargu/couchdb-designer
Advanced tools
Comparing version 0.6.0 to 0.6.1
@@ -34,32 +34,36 @@ "use strict"; | ||
return new Promise((resolve, reject) => { | ||
const testModule = createTestJavascriptModule(contextProps.contextId, fileContent); | ||
try { | ||
const testModule = createTestJavascriptModule(contextProps.contextId, fileContent); | ||
if (testModule && Object.keys(testModule).length > 0) { | ||
let testModuleKeys = Object.keys(testModule); | ||
if (testModule && Object.keys(testModule).length > 0) { | ||
let testModuleKeys = Object.keys(testModule); | ||
if (!fileStats.isLib && testModuleKeys.length === 1 && testModuleKeys[0] === fileStats.name) { | ||
const mockFunction = (0, _createMockFunction.default)(fileStats, contextProps, testModuleKeys[0], testModule[testModuleKeys[0]]); | ||
resolve({ | ||
[fileStats.name]: mockFunction | ||
}); | ||
} else { | ||
let testElementsObject = { | ||
__sourceProperties__: fileStats | ||
}; | ||
if (!fileStats.isLib && testModuleKeys.length === 1 && testModuleKeys[0] === fileStats.name) { | ||
const mockFunction = (0, _createMockFunction.default)(fileStats, contextProps, testModuleKeys[0], testModule[testModuleKeys[0]]); | ||
resolve({ | ||
[fileStats.name]: mockFunction | ||
}); | ||
} else { | ||
let testElementsObject = { | ||
__sourceProperties__: fileStats | ||
}; | ||
for (let moduleElementName of testModuleKeys) { | ||
if (typeof testModule[moduleElementName] === 'function') { | ||
const mockFunction = (0, _createMockFunction.default)(fileStats, contextProps, moduleElementName, testModule[moduleElementName]); | ||
testElementsObject[moduleElementName] = mockFunction; | ||
} else { | ||
testElementsObject[moduleElementName] = testModule[moduleElementName]; | ||
for (let moduleElementName of testModuleKeys) { | ||
if (typeof testModule[moduleElementName] === 'function') { | ||
const mockFunction = (0, _createMockFunction.default)(fileStats, contextProps, moduleElementName, testModule[moduleElementName]); | ||
testElementsObject[moduleElementName] = mockFunction; | ||
} else { | ||
testElementsObject[moduleElementName] = testModule[moduleElementName]; | ||
} | ||
} | ||
resolve({ | ||
[fileStats.name]: testElementsObject | ||
}); | ||
} | ||
resolve({ | ||
[fileStats.name]: testElementsObject | ||
}); | ||
} else { | ||
reject(`The module ${fileStats.filePath} does not exist't export anything! You must export function/s with module.exports = {...}`); | ||
} | ||
} else { | ||
reject(`The module ${fileStats.filePath} does not exist't export anything! You must export function/s with module.exports = {...}`); | ||
} catch (moduleError) { | ||
reject(`Can not evaluate ${fileStats.filePath}\n ${moduleError.message}`); | ||
} | ||
@@ -66,0 +70,0 @@ }); |
{ | ||
"name": "@zargu/couchdb-designer", | ||
"version": "0.6.0", | ||
"version": "0.6.1", | ||
"description": "Create and testing couchdb design document form directory structure.", | ||
@@ -5,0 +5,0 @@ "main": "build/index.js", |
@@ -9,3 +9,3 @@ import {testEnvironment} from '../../build/testing/testEnvironment'; | ||
const isArray = Array.isArray; | ||
return eval(fileContent); | ||
return eval(fileContent); | ||
} | ||
@@ -16,24 +16,28 @@ | ||
return new Promise((resolve, reject) => { | ||
const testModule = createTestJavascriptModule(contextProps.contextId, fileContent); | ||
if(testModule && Object.keys(testModule).length > 0){ | ||
let testModuleKeys = Object.keys(testModule); | ||
if(!fileStats.isLib && testModuleKeys.length === 1 && testModuleKeys[0] === fileStats.name){ | ||
const mockFunction = createMockFunction(fileStats, contextProps, testModuleKeys[0], testModule[testModuleKeys[0]]); | ||
resolve({[fileStats.name]:mockFunction}); | ||
try{ | ||
const testModule = createTestJavascriptModule(contextProps.contextId, fileContent); | ||
if(testModule && Object.keys(testModule).length > 0){ | ||
let testModuleKeys = Object.keys(testModule); | ||
if(!fileStats.isLib && testModuleKeys.length === 1 && testModuleKeys[0] === fileStats.name){ | ||
const mockFunction = createMockFunction(fileStats, contextProps, testModuleKeys[0], testModule[testModuleKeys[0]]); | ||
resolve({[fileStats.name]:mockFunction}); | ||
}else{ | ||
let testElementsObject = {__sourceProperties__:fileStats}; | ||
for(let moduleElementName of testModuleKeys){ | ||
if(typeof testModule[moduleElementName] === 'function'){ | ||
const mockFunction = createMockFunction(fileStats,contextProps,moduleElementName,testModule[moduleElementName]); | ||
testElementsObject[moduleElementName] = mockFunction; | ||
}else{ | ||
testElementsObject[moduleElementName] = testModule[moduleElementName]; | ||
} | ||
} | ||
resolve({[fileStats.name]:testElementsObject}); | ||
} | ||
}else{ | ||
let testElementsObject = {__sourceProperties__:fileStats}; | ||
for(let moduleElementName of testModuleKeys){ | ||
if(typeof testModule[moduleElementName] === 'function'){ | ||
const mockFunction = createMockFunction(fileStats,contextProps,moduleElementName,testModule[moduleElementName]); | ||
testElementsObject[moduleElementName] = mockFunction; | ||
}else{ | ||
testElementsObject[moduleElementName] = testModule[moduleElementName]; | ||
} | ||
} | ||
resolve({[fileStats.name]:testElementsObject}); | ||
} | ||
}else{ | ||
reject(`The module ${fileStats.filePath} does not exist't export anything! You must export function/s with module.exports = {...}`); | ||
} | ||
reject(`The module ${fileStats.filePath} does not exist't export anything! You must export function/s with module.exports = {...}`); | ||
} | ||
}catch(moduleError){ | ||
reject(`Can not evaluate ${fileStats.filePath}\n ${moduleError.message}`); | ||
} | ||
}); | ||
@@ -40,0 +44,0 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
183019
3688