Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
language: node_js
node_js:
- v8
- v7
- v6
- v9
- v8
- v7
- v6
before_install:
- npm install -g npm
- npm install -g codecov
Expand All @@ -19,7 +20,7 @@ deploy:
tags: true
repo: express-vue/vue-pronto
api_key:
secure: L6HD8tWjxQCtAnW+fXe3YT0heYX5/a4O2K1lMP+F48ZXYRhtsi0uePOWnCcF9M8f8/0t1vKR6RSx4W+9wI25dtb6kGXhPmrMffHioDlQ7IorPEu9I36LrSzLR8yX2AkuEg8M1f1XjSHQBlfFNKV0db+U+hFG9hScQzOlJEJ5KH8cwTfkNaXT6Co6oLi1k8RyGTIJ14m5RUxqyv8tnrhRYYFXbtPmx038ePLMgfQ9xW0gvPFjOCpl3JlUdwyQLGBgjypLt4MMeNxbUWoPuGSLBxV6masrxagqYYMaW+yFMhWJg7Cks1eERDuKSnp/2wzdnnwHN3wWEz0c7k6DFvmrF64dbLmsdpMvrZpnCIQoNx5Wkm2nTSiLWpcC7vuiswE5XWTMKcITpw6a1oyY8J0Uvt41JxvoNrJAWT6d9OOrOHvUxGPRs6YXjhUm/fslfvE84BMvwSWHah8jGtUxJY7cm7mNOoWGW47WUb424HJ0D2OgTjCHkKlCM6Q8SnJPS80QFN5Xx75P5CxlWnvtn26M00QFlg1YtLrGxw/9pUnemYUukvkzz3Xmu22IfaNnplPVLjKTVD5lVzv5ERHC4VENvdxHxuPh0p2OY3QkVFd9vyK9YqYNrYvQYCuLq+oegquKkxO43ESHFKcDzipUPTxsWAbPHTQ/6i2X7JSbjfRy7P8=
secure: Fw5+Z4k/meEj0s6uQkdQGu+w2TefFNBV37szGGFzhcCDmJocSZGoNB46YoMNayxtW6MKyxKJuXbbc+gcGQBdnWK/1FesOFPoKR2ok8774Gb83P5aO/AnQ1bSK5n4pqCSZdkADW15NyYs+ugDtHtVFB32SaHV4saSN6mJOGWTXH2y7PtVUcM05wYAGk/xZpqorApNa660bBdX0W123uTw29boG4fE/SNsxCNi6vuOi+JjtNJ4QsNSrEUPSgsghUUIZ1toiZhlBRjOrzs9RcAdRKQjuPfF6/WnShzBIVym5mPJvfROUleAAsBHw74CiNLv8iV6AtESklp9UBg6Tfn1vhMZir4dLVsAa9KE78gr7lDMGYyvUk/tr0chzkIro045dClE3dcD+ggFapxiOwEY6mTQ5SbS3hs/4FH3FsNugS0/abJSCZPhydJuhZ4T7V2sM4Y0TxnldXWib+kuMJwq0sHBfXf0akE6kpntjsuir6bAhLDA4U2XdGfbB9BjtBfkSpdicXmbmb+7Wh4E/j7e7M9dbfWzuDrrglBn3Pw5FWLUl9pMpwUJqO/YLhxVUaREiel0IkFzSa4Ejxqcaxfy6QZZZgqtnwo62v47fYnMUEXep77e3az1PXp+MeBTqa/hnkrjXcNEV3AxBlbLX9hg/4VwA5W2YkIbZmKUa/+rD1s=
addons:
code_climate:
repo_token: fdc3db1ac144125b5f5a11900fdaa719a4b882b55b4d5ea307a21164e01cce8a
27 changes: 19 additions & 8 deletions lib/renderer/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,27 +39,28 @@ const findNodeModules = require("find-node-modules");
* @prop {{max: number, maxAge: number}} cacheOptions - cacheoptions for LRU cache
* @prop {String} rootPath
* @prop {String} vueVersion
* @prop {VueOptionsType} head
* @prop {(VueOptionsType|Object)} head
* @prop {Object} data
*/

class Renderer {
/**
* @param {ConfigObjectType} options - options for constructor
* @param {(ConfigObjectType|Object)} [options={}] - options for constructor
* @property {{max: number, maxAge: number}} cacheOptions - cacheoptions for LRU cache
* @property {LRU} lruCache - LRU Cache
* @property {vueServerRenderer} renderer - instance of vue server renderer
* @property {String} rootPath
* @property {String} nodeModulesPath
* @property {String} vueVersion
*/
constructor(options) {
constructor(options = {}) {

this.cacheOptions = options.cacheOptions || {
max: 500,
maxAge: 1000 * 60 * 60,
};
this.lruCache = LRU(this.cacheOptions);
this.rootPath = options.rootPath;
this.rootPath = options.rootPath || this.FindRootPath();
this.head = options.head || {};
this.data = options.data || {};
this.vueVersion = options.vueVersion || "2.5.13";
Expand All @@ -74,14 +75,24 @@ class Renderer {
} else {
this.head.scripts = [script];
}
this.nodeModulesPath = this.FindNodeModules();
this.nodeModulesPath = this.FindNodeModules(this.rootPath);
}
/**
* @returns {String}
*/
FindRootPath() {
const currentPath = path.resolve(__dirname);
const nodeModulesPath = this.FindNodeModules(currentPath);
const rootPath = path.resolve(nodeModulesPath, "../");
return rootPath;
}
/**
* @param {String} cwdPath
* @returns {String}
*/
FindNodeModules() {
const nodeModulesPath = findNodeModules({cwd: this.rootPath});
const nodeModulesPathResolved = path.join(this.rootPath, nodeModulesPath[0]);
FindNodeModules(cwdPath) {
const nodeModulesPath = findNodeModules({cwd: cwdPath});
const nodeModulesPathResolved = path.join(cwdPath, nodeModulesPath[0]);
return nodeModulesPathResolved;
}
/**
Expand Down
25 changes: 25 additions & 0 deletions tests/renderer.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.