cmacc-compiler
Advanced tools
Comparing version 1.0.8 to 1.0.9
{ | ||
"name": "cmacc-compiler", | ||
"version": "1.0.8", | ||
"version": "1.0.9", | ||
"description": "Cmacc Compiler", | ||
@@ -10,2 +10,4 @@ "main": "src/index.js", | ||
"async": "^2.0.1", | ||
"cmacc-lib-entity": "^1.0.0", | ||
"find-root": "^1.0.0", | ||
"marked": "^0.3.5", | ||
@@ -12,0 +14,0 @@ "request": "^2.74.0", |
var fs = require('fs'); | ||
var url = require('url'); | ||
var path = require('path'); | ||
@@ -29,4 +30,4 @@ var cash = {} | ||
if(urlObj.protocol === 'file:'){ | ||
var path = decodeURI(urlObj.pathname); | ||
return fs.readFileSync(path, 'utf8'); | ||
var location = decodeURI(urlObj.pathname); | ||
return fs.readFileSync(location, 'utf8'); | ||
} | ||
@@ -53,2 +54,10 @@ | ||
if(urlObj.protocol === 'npm:' || urlObj.protocol === 'yarn:'){ | ||
var findRoot = require('find-root'); | ||
var packageRoot = findRoot(process.cwd()) | ||
var nodeModules = path.join(packageRoot, 'node_modules') | ||
var location = path.join(nodeModules, decodeURI(urlObj.host), decodeURI(urlObj.pathname)); | ||
return fs.readFileSync(location, 'utf8'); | ||
} | ||
} | ||
@@ -60,5 +69,4 @@ | ||
} | ||
module.exports = fetch; |
@@ -700,2 +700,34 @@ var assert = require('assert'); | ||
describe('Npm', function () { | ||
describe('NpmImport.cmacc', function () { | ||
it('should import from node_modules NpmImport.cmacc', function () { | ||
var file = path.join(__dirname, 'parse', 'NpmImport.cmacc'); | ||
var result = parse('file://' + file); | ||
assert.deepEqual(result, { | ||
"$$file$$": "file:///Users/willemveelenturf/projects/commonaccord/cmacc-compiler/test/parse/NpmImport.cmacc", | ||
"$$text$$": "{{npmImport}}", | ||
"npmImport": { | ||
"$$file$$": "npm://cmacc-lib-entity/gender/He.cmacc", | ||
"He_She": { | ||
"$$obj$$": result.npmImport, | ||
"$$str$$": "He" | ||
}, | ||
"His_Her": { | ||
"$$obj$$": result.npmImport, | ||
"$$str$$": "His" | ||
}, | ||
"he_she": { | ||
"$$obj$$": result.npmImport, | ||
"$$str$$": "he" | ||
}, | ||
"his_her": { | ||
"$$obj$$": result.npmImport, | ||
"$$str$$": "his" | ||
} | ||
} | ||
}) | ||
}); | ||
}); | ||
}); | ||
}); |
Sorry, the diff of this file is not supported yet
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
102814
149
1935
7
+ Addedcmacc-lib-entity@^1.0.0
+ Addedfind-root@^1.0.0
+ Addedcmacc-lib-entity@1.0.0(transitive)
+ Addedfind-root@1.1.0(transitive)