@fimbul/wotan
Advanced tools
Comparing version 0.17.0-dev.20181208 to 0.17.0-dev.20181215
{ | ||
"name": "@fimbul/wotan", | ||
"version": "0.17.0-dev.20181208", | ||
"version": "0.17.0-dev.20181215", | ||
"description": "Pluggable TypeScript and JavaScript linter", | ||
@@ -47,4 +47,4 @@ "bin": "bin/main.js", | ||
"dependencies": { | ||
"@fimbul/mimir": "0.17.0-dev.20181205", | ||
"@fimbul/ymir": "0.17.0-dev.20181205", | ||
"@fimbul/mimir": "0.17.0-dev.20181215", | ||
"@fimbul/ymir": "0.17.0-dev.20181215", | ||
"bind-decorator": "^1.0.11", | ||
@@ -51,0 +51,0 @@ "chalk": "^2.3.0", |
@@ -7,3 +7,2 @@ "use strict"; | ||
const path = require("path"); | ||
const utils_1 = require("../../utils"); | ||
let DefaultBuiltinResolver = class DefaultBuiltinResolver { | ||
@@ -14,3 +13,3 @@ constructor(resolver) { | ||
get builtinPackagePath() { | ||
const resolved = path.dirname(this.resolver.resolve('@fimbul/mimir', path.join(__dirname, '../'.repeat(utils_1.OFFSET_TO_NODE_MODULES)), [])); | ||
const resolved = path.dirname(this.resolver.resolve('@fimbul/mimir', path.join(__dirname, '../'.repeat(3)), [])); | ||
Object.defineProperty(this, 'builtinPackagePath', { value: resolved }); | ||
@@ -17,0 +16,0 @@ return resolved; |
@@ -112,3 +112,3 @@ "use strict"; | ||
mapProcessor(processor, basedir) { | ||
return processor && this.resolver.resolve(processor, basedir, Object.keys(require.extensions).filter((ext) => ext !== '.json' && ext !== '.node'), module.paths.slice(utils_1.OFFSET_TO_NODE_MODULES + 2)); | ||
return processor && this.resolver.resolve(processor, basedir, undefined, module.paths.slice(utils_1.OFFSET_TO_NODE_MODULES + 2)); | ||
} | ||
@@ -115,0 +115,0 @@ }; |
@@ -15,14 +15,12 @@ "use strict"; | ||
try { | ||
return require(name).Formatter; | ||
name = this.resolver.resolve(name); | ||
} | ||
catch (e) { | ||
if (e != undefined && e.code === 'MODULE_NOT_FOUND' && e.message === `Cannot find module '${name}'`) | ||
return; | ||
throw e; | ||
catch (_a) { | ||
return; | ||
} | ||
return this.resolver.require(name).Formatter; | ||
} | ||
loadCustomFormatter(name, basedir) { | ||
let resolved; | ||
try { | ||
resolved = this.resolver.resolve(name, basedir, Object.keys(require.extensions).filter((ext) => ext !== '.json' && ext !== '.node'), module.paths.slice(utils_1.OFFSET_TO_NODE_MODULES + 1)); | ||
name = this.resolver.resolve(name, basedir, undefined, module.paths.slice(utils_1.OFFSET_TO_NODE_MODULES + 2)); | ||
} | ||
@@ -32,3 +30,3 @@ catch (_a) { | ||
} | ||
return this.resolver.require(resolved).Formatter; | ||
return this.resolver.require(name).Formatter; | ||
} | ||
@@ -35,0 +33,0 @@ }; |
@@ -1,7 +0,10 @@ | ||
import { Resolver } from '@fimbul/ymir'; | ||
import { Resolver, DirectoryService } from '@fimbul/ymir'; | ||
import { CachedFileSystem } from '../cached-file-system'; | ||
export declare class NodeResolver implements Resolver { | ||
private fs; | ||
constructor(fs: CachedFileSystem); | ||
resolve(id: string, basedir: string, extensions: ReadonlyArray<string>, paths?: ReadonlyArray<string>): string; | ||
private directories; | ||
private defaultExtensions; | ||
constructor(fs: CachedFileSystem, directories: DirectoryService); | ||
getDefaultExtensions(): ReadonlyArray<string>; | ||
resolve(id: string, basedir?: string, extensions?: ReadonlyArray<string>, paths?: ReadonlyArray<string>): string; | ||
require(id: string, options?: { | ||
@@ -8,0 +11,0 @@ cache?: boolean; |
@@ -5,9 +5,15 @@ "use strict"; | ||
const inversify_1 = require("inversify"); | ||
const ymir_1 = require("@fimbul/ymir"); | ||
const cached_file_system_1 = require("../cached-file-system"); | ||
const resolve = require("resolve"); | ||
let NodeResolver = class NodeResolver { | ||
constructor(fs) { | ||
constructor(fs, directories) { | ||
this.fs = fs; | ||
this.directories = directories; | ||
this.defaultExtensions = Object.keys(require.extensions).filter((ext) => ext !== '.json' && ext !== '.node'); | ||
} | ||
resolve(id, basedir, extensions, paths) { | ||
getDefaultExtensions() { | ||
return this.defaultExtensions; | ||
} | ||
resolve(id, basedir = this.directories.getCurrentDirectory(), extensions = this.defaultExtensions, paths) { | ||
return resolve.sync(id, { | ||
@@ -29,5 +35,5 @@ basedir, | ||
inversify_1.injectable(), | ||
tslib_1.__metadata("design:paramtypes", [cached_file_system_1.CachedFileSystem]) | ||
tslib_1.__metadata("design:paramtypes", [cached_file_system_1.CachedFileSystem, ymir_1.DirectoryService]) | ||
], NodeResolver); | ||
exports.NodeResolver = NodeResolver; | ||
//# sourceMappingURL=resolver.js.map |
@@ -1,7 +0,8 @@ | ||
import { RuleLoaderHost, RuleConstructor, BuiltinResolver } from '@fimbul/ymir'; | ||
import { RuleLoaderHost, RuleConstructor, BuiltinResolver, Resolver } from '@fimbul/ymir'; | ||
export declare class NodeRuleLoader implements RuleLoaderHost { | ||
private builtinResolver; | ||
private resolver; | ||
constructor(resolver: BuiltinResolver); | ||
constructor(builtinResolver: BuiltinResolver, resolver: Resolver); | ||
loadCoreRule(name: string): RuleConstructor | undefined; | ||
loadCustomRule(name: string, directory: string): RuleConstructor | undefined; | ||
} |
@@ -10,30 +10,26 @@ "use strict"; | ||
let NodeRuleLoader = class NodeRuleLoader { | ||
constructor(resolver) { | ||
constructor(builtinResolver, resolver) { | ||
this.builtinResolver = builtinResolver; | ||
this.resolver = resolver; | ||
} | ||
loadCoreRule(name) { | ||
name = this.builtinResolver.resolveRule(name); | ||
try { | ||
name = this.resolver.resolveRule(name); | ||
const rule = require(name).Rule; | ||
log('Found %s', name); | ||
return rule; | ||
name = this.resolver.resolve(name); | ||
} | ||
catch (e) { | ||
if (e != undefined && e.code === 'MODULE_NOT_FOUND') | ||
return; | ||
throw e; | ||
catch (_a) { | ||
return; | ||
} | ||
log('Found %s', name); | ||
return this.resolver.require(name).Rule; | ||
} | ||
loadCustomRule(name, directory) { | ||
try { | ||
name = path.join(directory, name); | ||
const rule = require(name).Rule; | ||
log('Found %s', name); | ||
return rule; | ||
name = this.resolver.resolve(path.join(directory, name), directory); | ||
} | ||
catch (e) { | ||
if (e != undefined && e.code === 'MODULE_NOT_FOUND' && e.message === `Cannot find module '${name}'`) | ||
return; | ||
throw e; | ||
catch (_a) { | ||
return; | ||
} | ||
log('Found %s', name); | ||
return this.resolver.require(name).Rule; | ||
} | ||
@@ -43,5 +39,5 @@ }; | ||
inversify_1.injectable(), | ||
tslib_1.__metadata("design:paramtypes", [ymir_1.BuiltinResolver]) | ||
tslib_1.__metadata("design:paramtypes", [ymir_1.BuiltinResolver, ymir_1.Resolver]) | ||
], NodeRuleLoader); | ||
exports.NodeRuleLoader = NodeRuleLoader; | ||
//# sourceMappingURL=rule-loader-host.js.map |
@@ -7,3 +7,2 @@ import { ProcessorConstructor, Resolver, CacheFactory } from '@fimbul/ymir'; | ||
loadProcessor(path: string): ProcessorConstructor; | ||
private requireProcessor; | ||
} |
@@ -7,3 +7,2 @@ "use strict"; | ||
const utils_1 = require("../utils"); | ||
const bind_decorator_1 = require("bind-decorator"); | ||
let ProcessorLoader = class ProcessorLoader { | ||
@@ -15,24 +14,10 @@ constructor(resolver, cache) { | ||
loadProcessor(path) { | ||
return utils_1.resolveCachedResult(this.cache, path, this.requireProcessor); | ||
} | ||
requireProcessor(path) { | ||
try { | ||
const result = this.resolver.require(path).Processor; | ||
return utils_1.resolveCachedResult(this.cache, path, (p) => { | ||
const result = this.resolver.require(p).Processor; | ||
if (result === undefined) | ||
throw new ymir_1.ConfigurationError(`'${path}' has no export named 'Processor'.`); | ||
throw new ymir_1.ConfigurationError(`'${p}' has no export named 'Processor'.`); | ||
return result; | ||
} | ||
catch (e) { | ||
if (e != undefined && e.code === 'MODULE_NOT_FOUND' && e.message === `Cannot find module '${path}'`) | ||
throw new ymir_1.ConfigurationError(e.message); | ||
throw e; | ||
} | ||
}); | ||
} | ||
}; | ||
tslib_1.__decorate([ | ||
bind_decorator_1.default, | ||
tslib_1.__metadata("design:type", Function), | ||
tslib_1.__metadata("design:paramtypes", [String]), | ||
tslib_1.__metadata("design:returntype", Object) | ||
], ProcessorLoader.prototype, "requireProcessor", null); | ||
ProcessorLoader = tslib_1.__decorate([ | ||
@@ -39,0 +24,0 @@ inversify_1.injectable(), |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
6
273316
3392
+ Added@fimbul/mimir@0.17.0-dev.20181215(transitive)
+ Added@fimbul/ymir@0.17.0-dev.20181215(transitive)
- Removed@fimbul/mimir@0.17.0-dev.20181205(transitive)
- Removed@fimbul/ymir@0.17.0-dev.20181205(transitive)