krakenjs / file-resolver Goto Github PK
View Code? Open in Web Editor NEWUsed in kraken based projects for resolving files given the locale , file name, and the file extension.
License: Other
Used in kraken based projects for resolving files given the locale , file name, and the file extension.
License: Other
Getting AssertionError on Windows due to the backslashes in the Windows environment. Need to normalize the URL.
Work-around: Don't use windows :) (Still looking for another work-around)
AssertionError: Provided start directory is not within root or one of its subdirectories.
I added the following logs to the file:
/node_modules/bundalo/node_modules/file-resolver/lib/util.js
exports.locate = function locate(name, root, start) {
var removed, file, parent;
console.log("------------");
console.log("start:");
console.log(start);
console.log("------------");
console.log("root:");
console.log(root);
console.log("------------");
assert(~start.indexOf(root), 'Provided start directory is not within root or one of its subdirectories.');
Output of the above logs:
------------
start:
locales\US\en
------------
root:
locales/
------------
Replicated with the Test Suite:
# resolve with a bogus locale object
assert.js:86
throw new assert.AssertionError({
^
AssertionError: Provided start directory is not within root or one of its subdir
ectories.
at Object.locate (Z:\Projects\file-resolver\lib\util.js:64:5)
at Object.proto._locate (Z:\Projects\file-resolver\index.js:33:24)
at Object.proto.resolve (Z:\Projects\file-resolver\index.js:51:26)
at Test.<anonymous> (Z:\Projects\file-resolver\test\index.js:116:28)
at Test.bound [as _cb] (Z:\Projects\file-resolver\node_modules\tape\lib\test
.js:62:32)
at Test.run (Z:\Projects\file-resolver\node_modules\tape\lib\test.js:75:10)
at Test.bound [as run] (Z:\Projects\file-resolver\node_modules\tape\lib\test
.js:62:32)
at Test._end (Z:\Projects\file-resolver\node_modules\tape\lib\test.js:141:11
)
at Test.bound [as _end] (Z:\Projects\file-resolver\node_modules\tape\lib\tes
t.js:62:32)
at Test.<anonymous> (Z:\Projects\file-resolver\node_modules\tape\lib\test.js
:140:40)
npm ERR! Test failed. See above for more details.```
For example, str = 'es_CLAC_B' should resolve to
lang='es'
country='CLAC_B'
https://github.com/krakenjs/file-resolver/blob/master/index.js#L32
If something is wrong with the locale object, for example it is an empty object {}
then _locate
will pass non-string arguments to path.join resulting in:
TypeError: Arguments to path.join must be strings
at path.js:360:15
at Array.filter (native)
at Object.exports.join (path.js:358:36)
at Object.proto._locate (/Users/medelman/src/krakex/kraken-examples/with.i18n/node_modules/engine-munger/node_modules/file-resolver/index.js:32:29)
Not sure if this would be considered over-protective of the module or not...
graceful-fs
versions lower than v4 reevaluate native fs
module source, which is not supported.
You should update your graceful-fs
dependency to v4 or later.
Tracking issue: nodejs/node#5213.
Hi team. I'm using Windows 7 64 bits, and I tried to run the latest version of the Kraken's examples (i.e., i18n, Shopping Cart, and others for Kraken v1.0.1) using production mode (NODE_ENV=production
), but the server always threw an 'Internal Server Error', because the compiled templates couldn't be found (.build/templates/**/*.js
files).
I debugged the source code, and found a problem with the 'util.js' file (line 67). This file is used by engine-munger
to resolve the templates' path, but didn't consider the OS dependency when working with slashes and backslashes (it fails on Windows platform).
The old line is: root : file.replace(name, ''),
A possible solution is: root : file.replace(path.normalize(name), ''),
Using this approach the file.replace
operation works as expected.
Thanks team for the great work with KrakenJS! I enjoy it :)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.