Skip to content

Commit

Permalink
[minor] try import over require.resolve if location is not found. Thi…
Browse files Browse the repository at this point in the history
…s allows better re-use of assets that are installed through the npm/node_modules folders
  • Loading branch information
3rd-Eden committed Nov 25, 2013
1 parent e452a67 commit edecd31
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/square.js
Expand Up @@ -1326,6 +1326,13 @@ Square.prototype.directive = function directive(data, extension, reference, seen
var location = path.resolve(reference, file)
, data = '';

//
// If it's not an absolute path, try to require.resolve the file.
//
if (!fs.existsSync(location)) try {
location = require.resolve(file);
} catch (e) { }

if (!fs.existsSync(location)) {
return self.critical(
'// [square] @%s statement %s in %s does not exist'
Expand Down

0 comments on commit edecd31

Please sign in to comment.