Skip to content

Commit

Permalink
Merge pull request #4227 from ember-cli/extract-process-relative-require
Browse files Browse the repository at this point in the history
Extract process relative require
  • Loading branch information
stefanpenner committed Jun 3, 2015
2 parents 91b717f + 49c5b37 commit 374679c
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 11 deletions.
4 changes: 2 additions & 2 deletions lib/preprocessors.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

var path = require('path');
var Registry = require('./models/registry');
var requireLocal = require('./utilities/require-local');
var relativeRequire = require('process-relative-require');
var debug = require('debug')('ember-cli:preprocessors');

/**
Expand Down Expand Up @@ -122,7 +122,7 @@ module.exports.preprocessMinifyCss = function(tree, options) {

var plugin = plugins[0];

return requireLocal(plugin.name).call(null, tree, options);
return relativeRequire(plugin.name).call(null, tree, options);
};

module.exports.preprocessCss = function(tree, inputPath, outputPath, options) {
Expand Down
6 changes: 3 additions & 3 deletions lib/preprocessors/javascript-plugin.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

var Plugin = require('./plugin');
var requireLocal = require('../utilities/require-local');
var Plugin = require('./plugin');
var relativeRequire = require('process-relative-require');

function JavascriptPlugin () {
this.type = 'js';
Expand All @@ -20,7 +20,7 @@ JavascriptPlugin.prototype.toTree = function(tree, inputPath, outputPath, option
options.destDir = outputPath;
}

return requireLocal(this.name).call(null, tree, options);
return relativeRequire(this.name).call(null, tree, options);
};

module.exports = JavascriptPlugin;
7 changes: 4 additions & 3 deletions lib/preprocessors/style-plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

var path = require('path');
var Plugin = require('./plugin');
var requireLocal = require('../utilities/require-local');
var merge = require('lodash/object/merge');
var SilentError = require('../errors/silent');
var mergeTrees = require('broccoli-merge-trees');

var relativeRequire = require('process-relative-require');

function StylePlugin () {
this.type = 'css';
this._superConstructor.apply(this, arguments);
Expand All @@ -26,7 +27,7 @@ StylePlugin.prototype.toTree = function(inputTree, inputPath, outputPath, option

var trees = Object.keys(paths).map(function (file) {
var ext = self.getExt(inputTreeRoot, inputPath, file);

// Throw an error if no valid file was found
if (!ext) {
var attemptedExtensions;
Expand All @@ -41,7 +42,7 @@ StylePlugin.prototype.toTree = function(inputTree, inputPath, outputPath, option
var input = path.join(inputPath, file + '.' + ext);
var output = paths[file];

return requireLocal(self.name).call(null, [inputTree], input, output, options);
return relativeRequire(self.name).call(null, [inputTree], input, output, options);
});

return readTree(mergeTrees(trees));
Expand Down
6 changes: 3 additions & 3 deletions lib/preprocessors/template-plugin.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

var Plugin = require('./plugin');
var requireLocal = require('../utilities/require-local');
var Plugin = require('./plugin');
var relativeRequire = require('process-relative-require');

function TemplatePlugin () {
this.type = 'template';
Expand All @@ -13,7 +13,7 @@ TemplatePlugin.prototype.constructor = TemplatePlugin;
TemplatePlugin.prototype._superConstructor = Plugin;

TemplatePlugin.prototype.toTree = function(tree) {
return requireLocal(this.name).call(null, tree, {
return relativeRequire(this.name).call(null, tree, {
extensions: this.ext,
module: true
});
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@
"nopt": "^3.0.1",
"npm": "^2.7.6",
"pleasant-progress": "^1.0.2",
"process-relative-require": "^1.0.0",
"promise-map-series": "^0.2.1",
"proxy-middleware": "0.11.0",
"quick-temp": "0.1.2",
Expand Down

0 comments on commit 374679c

Please sign in to comment.