Skip to content

Commit

Permalink
Refactor out the path concatenation so it doesn't happen every time
Browse files Browse the repository at this point in the history
  • Loading branch information
torarvid committed Jun 19, 2017
1 parent d78d8fa commit 6aea841
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ var compile = module.prototype._compile
var path = require('path')

var index = __dirname.indexOf('node_modules')
var baseDirectory = (index < 1) ? __dirname : __dirname.substr(0, index - 1)
var nodeModulesDir = (index < 1) ? path.join(__dirname, 'node_modules') : __dirname.substr(0, index + 12)

module.prototype._compile = function (content, filename) {
var isThirdParty = filename.startsWith(path.join(baseDirectory, 'node_modules'))
var isThirdParty = filename.startsWith(nodeModulesDir)
if (!isThirdParty) {
content = "'use strict';" + content
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "auto-strict",
"version": "0.0.3",
"version": "0.0.4",
"description": "Add 'use strict'; to all code not in node_modules",
"main": "index.js",
"author": {
Expand Down

0 comments on commit 6aea841

Please sign in to comment.