Skip to content
This repository has been archived by the owner on May 29, 2019. It is now read-only.

Commit

Permalink
fix(index): resolve schemas relative to __dirname (#536)
Browse files Browse the repository at this point in the history
  • Loading branch information
MirrorBytes authored and michael-ciniawsky committed Jun 8, 2017
1 parent 0271b39 commit 8766821
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ var Chunk = require("webpack/lib/Chunk");
var OrderUndefinedError = require("./OrderUndefinedError");
var loaderUtils = require("loader-utils");
var validateOptions = require('schema-utils');
var path = require('path');

var NS = fs.realpathSync(__dirname);

Expand Down Expand Up @@ -124,7 +125,7 @@ function ExtractTextPlugin(options) {
if(isString(options)) {
options = { filename: options };
} else {
validateOptions('./schema/plugin.json', options, 'Extract Text Plugin');
validateOptions(path.resolve(__dirname, './schema/plugin.json'), options, 'Extract Text Plugin');
}
this.filename = options.filename;
this.id = options.id != null ? options.id : ++nextId;
Expand Down Expand Up @@ -203,7 +204,7 @@ ExtractTextPlugin.prototype.extract = function(options) {
if(Array.isArray(options) || isString(options) || typeof options.options === "object" || typeof options.query === 'object') {
options = { loader: options };
} else {
validateOptions('./schema/loader.json', options, 'Extract Text Plugin (Loader)');
validateOptions(path.resolve(__dirname, './schema/loader.json'), options, 'Extract Text Plugin (Loader)');
}
var loader = options.use ||  options.loader;
var before = options.fallback || options.fallbackLoader || [];
Expand Down

3 comments on commit 8766821

@khanglu
Copy link

@khanglu khanglu commented on 8766821 Jun 8, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you so much, this was breaking the whole internet for half an hour.

@vladik7244
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be better to require schemas. Validate options support first argument to be object (JSON-schema)

@michael-ciniawsky
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vladik7244 I wanted trying to fix it in schema-utils first, but since it's not critical anymore, feel free to send a 'style' PR with a cleaner solution :), either here or in schema-utils or in both :D

Please sign in to comment.