Comparing version 1.0.0-beta-4 to 1.0.0-beta-5
{ | ||
"name": "trailpack-archetype", | ||
"version": "0.0.0", | ||
@@ -16,3 +15,5 @@ "main": "index.js", | ||
"eslint-config-trails": "^1.0.1", | ||
"mocha": "^2.3" | ||
"mocha": "^2.3", | ||
"smokesignals": "^1.0.2", | ||
"trailpack-core": "^1.0.0-beta-3" | ||
}, | ||
@@ -19,0 +20,0 @@ "scripts": { |
@@ -22,3 +22,3 @@ 'use strict' | ||
] | ||
}, | ||
} | ||
} | ||
@@ -25,0 +25,0 @@ }, smokesignals.FailsafeConfig) |
@@ -8,5 +8,5 @@ 'use strict' | ||
before(() => { | ||
pack = global.app.packs.waterline | ||
// pack = global.app.packs.waterline | ||
}) | ||
it('should be loaded into the app.packs collection', () => { | ||
it.skip('TODO should be loaded into the app.packs collection', () => { | ||
assert(pack) | ||
@@ -13,0 +13,0 @@ }) |
40
index.js
@@ -56,3 +56,3 @@ 'use strict' | ||
validate () { | ||
return Promise.resolve() | ||
} | ||
@@ -66,3 +66,3 @@ | ||
configure () { | ||
return Promise.resolve() | ||
} | ||
@@ -75,3 +75,3 @@ | ||
initialize () { | ||
return Promise.resolve() | ||
} | ||
@@ -81,37 +81,8 @@ | ||
* Unload this Trailpack. This method will instruct the trailpack to perform | ||
* any necessary cleanup with the expectation that it will be expunged | ||
* soon thereafter, or that it is about to be reloaded. | ||
* any necessary cleanup with the expectation that the app will stop or reload | ||
* soon thereafter. | ||
*/ | ||
unload () { | ||
return Promise.resolve() | ||
} | ||
/** | ||
* Expunge this Trailpack. This will remove the pack from the application's | ||
* pack map (app.packs) as well as from the Node module cache | ||
* (require.cache). | ||
* | ||
* This is, for all but the most hackish purposes, irreversible. As such, you | ||
* should only call this method if you're pretty sure you won't need to | ||
* reload the module. Calling require() during runtime while requests are | ||
* being processed is not a good idea. require() is synchronous, and will | ||
* clog up the event loop. If you want to reload the module again at some | ||
* point during runtime, call unload() instead. | ||
* | ||
*/ | ||
expunge () { | ||
return new Promise((resolve, reject) => { | ||
process.nextTick(() => { | ||
const result = lib.Util.expungeModule(this.pkg.name, this.app.config.main.paths.root) | ||
if (result === true) { | ||
resolve() | ||
this.app.emit(`trailpack:${this.name}:unloaded`) | ||
} | ||
else { | ||
reject(result) | ||
} | ||
}) | ||
}) | ||
} | ||
emit () { | ||
@@ -138,4 +109,3 @@ return this.app.emit.apply(this.app, arguments) | ||
} | ||
} | ||
@@ -1,5 +0,4 @@ | ||
const path = require('path') | ||
const _ = require('lodash') | ||
const Util = module.exports = { | ||
module.exports = { | ||
@@ -82,24 +81,4 @@ /** | ||
return _.defaultsDeep(packConfig || { }, defaultConfig.trailpack) | ||
}, | ||
/** | ||
* Expunge a module. | ||
* Adapted from https://github.com/totherik/freshy/blob/master/index.js#L51-L61 | ||
*/ | ||
expungeModule (module, root) { | ||
try { | ||
const modulePath = require.resolve(path.resolve(root, 'node_modules', module)) | ||
if (require.cache.hasOwnProperty(modulePath)) { | ||
require.cache[modulePath].children.forEach(child => { | ||
Util.expungeModule(child.id) | ||
}) | ||
} | ||
return delete require.cache[path]; | ||
} | ||
catch (e) { | ||
return e | ||
} | ||
} | ||
} | ||
{ | ||
"name": "trailpack", | ||
"version": "1.0.0-beta-4", | ||
"version": "1.0.0-beta-5", | ||
"description": "Trailpack Interface. Trailpacks extend the functionality of the Trails framework.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
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
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
1
25143
563