From 6aea841e077edf10dd2a0d401c5de2421b71891d Mon Sep 17 00:00:00 2001 From: Tor Arvid Lund Date: Mon, 19 Jun 2017 23:44:17 +0200 Subject: [PATCH] Refactor out the path concatenation so it doesn't happen every time --- index.js | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index 8e9656f..166edf8 100644 --- a/index.js +++ b/index.js @@ -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 } diff --git a/package.json b/package.json index 526f019..3078e69 100644 --- a/package.json +++ b/package.json @@ -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": {