From b3944aac6c3952f2971148cd40db643a399caaed Mon Sep 17 00:00:00 2001 From: David Oliveros Date: Fri, 13 Mar 2015 01:41:05 -0600 Subject: [PATCH 1/2] Added option "newline" --- README.md | 1 + index.js | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 75c4bfd..7d84d64 100644 --- a/README.md +++ b/README.md @@ -39,6 +39,7 @@ function doStuff() { # opts `exclude`: array of file extensions to exclude. defaults to `['json']` +`newline`: boolean to append a newline after "use strict". defaults to `true` # install diff --git a/index.js b/index.js index 30b027d..354da50 100644 --- a/index.js +++ b/index.js @@ -8,6 +8,8 @@ function strictify(file, opts) { opts = opts || {}; opts.exclude = ['json'].concat(opts.exclude||[]); + var tail = opts.newline !== false ? '\n' : ''; + var stream = through(write, end); var applied = false; @@ -20,7 +22,7 @@ function strictify(file, opts) { function write(buf) { if (!applied && !excluded) { - stream.queue('"use strict";\n'); + stream.queue('"use strict";'+tail); applied = true; } stream.queue(buf); From 49c8e867e30184ec1369b217d362143fe563c5a9 Mon Sep 17 00:00:00 2001 From: David Oliveros Date: Thu, 16 Jul 2015 13:13:12 -0500 Subject: [PATCH 2/2] Defaulted opts.newline to true --- README.md | 2 +- index.js | 2 +- package.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 7d84d64..9a2f082 100644 --- a/README.md +++ b/README.md @@ -39,7 +39,7 @@ function doStuff() { # opts `exclude`: array of file extensions to exclude. defaults to `['json']` -`newline`: boolean to append a newline after "use strict". defaults to `true` +`newline`: boolean to append a newline after "use strict". defaults to `false` # install diff --git a/index.js b/index.js index 354da50..622e3fd 100644 --- a/index.js +++ b/index.js @@ -8,7 +8,7 @@ function strictify(file, opts) { opts = opts || {}; opts.exclude = ['json'].concat(opts.exclude||[]); - var tail = opts.newline !== false ? '\n' : ''; + var tail = opts.newline ? '\n' : ''; var stream = through(write, end); var applied = false; diff --git a/package.json b/package.json index ffbaf1f..50b655d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "strictify", - "version": "0.2.0", + "version": "0.2.1", "description": "browserify v2 plugin for enforcing strict mode", "main": "index.js", "dependencies": {