Skip to content

Commit cb9b00d

Browse files
Initial commit
0 parents  commit cb9b00d

21 files changed

+469
-0
lines changed

.editorconfig

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Editor config
2+
# http://EditorConfig.org
3+
4+
# This EditorConfig overrides any parent EditorConfigs
5+
root = true
6+
7+
# Default rules applied to all file types
8+
[*]
9+
10+
# No trailing spaces, newline at EOF
11+
charset = utf-8
12+
trim_trailing_whitespace = true
13+
insert_final_newline = true
14+
15+
# 2 space indentation
16+
indent_style = space
17+
indent_size = 2
18+
19+
# JavaScript-specific settings
20+
[*.js]
21+
quote_type = single
22+
continuation_indent_size = 2
23+
curly_bracket_next_line = false
24+
indent_brace_style = BSD
25+
spaces_around_operators = true
26+
spaces_around_brackets = none

.gitattributes

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Specifies how Git should treat certain file types
2+
# https://git-scm.com/book/en/v2/Customizing-Git-Git-Attributes
3+
4+
# Convert all line endings to CRLF, so they work with Windows programs
5+
* text=auto
6+
7+
# Explicitly declare text files you want to always be normalized and converted
8+
# to native line endings on checkout.
9+
*.txt text
10+
*.html text
11+
*.md text
12+
*.css text
13+
*.scss text
14+
*.min text
15+
*.map text
16+
*.js text
17+
*.json text
18+
*.config text
19+
*.xml text
20+
*.njsproj text
21+
*.java text
22+
*.sql text
23+
*.iml text
24+
*.svg text
25+
26+
# Declare files that will always have CRLF line endings on checkout.
27+
*.sln text eol=crlf
28+
*.csproj text eol=crlf
29+
*.jsproj text eol=crlf
30+
*.njsproj text eol=crlf
31+
*.vbproj text eol=crlf
32+
33+
# Denote all files that are truly binary and should not be modified.
34+
*.gif binary
35+
*.png binary
36+
*.jpg binary
37+
*.jpeg binary
38+
*.bmp binary
39+
*.dll binary
40+
*.exe binary

.gitignore

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Specifies intentionally untracked files to ignore when using Git
2+
# http://git-scm.com/docs/gitignore
3+
4+
**/*~
5+
**/._*
6+
**/.DS_Store
7+
npm-debug.log
8+
/.idea
9+
/node_modules
10+
/test/node_modules

.jscsrc

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
{
2+
"excludeFiles": [
3+
"node_modules/**"
4+
],
5+
"requireCurlyBraces": [
6+
"if",
7+
"else",
8+
"for",
9+
"while",
10+
"do",
11+
"try",
12+
"catch"
13+
],
14+
"requireOperatorBeforeLineBreak": true,
15+
"requireCamelCaseOrUpperCaseIdentifiers": true,
16+
"maximumLineLength": {
17+
"value": 120,
18+
"allowComments": true,
19+
"allowRegex": true
20+
},
21+
"validateIndentation": 2,
22+
"validateQuoteMarks": "'",
23+
24+
"disallowMultipleLineStrings": true,
25+
"disallowMixedSpacesAndTabs": true,
26+
"disallowTrailingWhitespace": true,
27+
"disallowSpaceAfterPrefixUnaryOperators": true,
28+
"disallowMultipleVarDecl": null,
29+
"disallowKeywordsOnNewLine": [],
30+
31+
"requireSpaceAfterKeywords": [
32+
"if",
33+
"else",
34+
"for",
35+
"while",
36+
"do",
37+
"switch",
38+
"return",
39+
"try",
40+
"catch"
41+
],
42+
"requireSpaceBeforeBinaryOperators": [
43+
"=", "+=", "-=", "*=", "/=", "%=", "<<=", ">>=", ">>>=",
44+
"&=", "|=", "^=", "+=",
45+
46+
"+", "-", "*", "/", "%", "<<", ">>", ">>>", "&",
47+
"|", "^", "&&", "||", "===", "==", ">=",
48+
"<=", "<", ">", "!=", "!=="
49+
],
50+
"requireSpaceAfterBinaryOperators": true,
51+
"requireSpacesInConditionalExpression": true,
52+
"requireSpaceBeforeBlockStatements": true,
53+
"requireSpacesInForStatement": true,
54+
"requireLineFeedAtFileEnd": true,
55+
"requireSpacesInFunctionExpression": {
56+
"beforeOpeningCurlyBrace": true
57+
},
58+
"disallowSpacesInAnonymousFunctionExpression": {
59+
"beforeOpeningRoundBrace": true
60+
},
61+
"disallowSpacesInsideObjectBrackets": "all",
62+
"disallowSpacesInsideArrayBrackets": "all",
63+
"disallowSpacesInsideParentheses": true,
64+
65+
"disallowMultipleLineBreaks": true,
66+
"disallowNewlineBeforeBlockStatements": true
67+
}

.jshintignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/node_modules

.jshintrc

+85
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
{
2+
// JSHint config
3+
// http://jshint.com/docs/options/
4+
5+
"maxerr" : 500, // {int} Maximum error before stopping
6+
7+
// Enforcing
8+
"bitwise" : true, // true: Prohibit bitwise operators (&, |, ^, etc.)
9+
"camelcase" : true, // true: Identifiers must be in camelCase
10+
"curly" : true, // true: Require {} for every new block or scope
11+
"eqeqeq" : true, // true: Require triple equals (===) for comparison
12+
"forin" : true, // true: Require filtering for..in loops with obj.hasOwnProperty()
13+
"immed" : true, // true: Require immediate invocations to be wrapped in parens e.g. `(function () { } ());`
14+
"indent" : 2, // {int} Number of spaces to use for indentation
15+
"latedef" : "nofunc", // true: Require variables/functions to be defined before being used
16+
"newcap" : true, // true: Require capitalization of all constructor functions e.g. `new F()`
17+
"noarg" : true, // true: Prohibit use of `arguments.caller` and `arguments.callee`
18+
"noempty" : true, // true: Prohibit use of empty blocks
19+
"nonew" : true, // true: Prohibit use of constructors for side-effects (without assignment)
20+
"plusplus" : false, // true: Prohibit use of `++` & `--`
21+
"quotmark" : "single", // Quotation mark consistency:
22+
"undef" : true, // true: Require all non-global variables to be declared (prevents global leaks)
23+
"unused" : "vars", // true: Require all defined variables be used
24+
"strict" : true, // true: Requires all functions run in ES5 Strict Mode
25+
"trailing" : true, // true: Prohibit trailing whitespaces
26+
"maxparams" : false, // {int} Max number of formal params allowed per function
27+
"maxdepth" : false, // {int} Max depth of nested blocks (within functions)
28+
"maxstatements" : false, // {int} Max number statements per function
29+
"maxcomplexity" : false, // {int} Max cyclomatic complexity per function
30+
"maxlen" : false, // {int} Max number of characters per line
31+
32+
// Relaxing
33+
"asi" : false, // true: Tolerate Automatic Semicolon Insertion (no semicolons)
34+
"boss" : true, // true: Tolerate assignments where comparisons would be expected
35+
"debug" : true, // true: Allow debugger statements e.g. browser breakpoints.
36+
"eqnull" : false, // true: Tolerate use of `== null`
37+
"es5" : false, // true: Allow ES5 syntax (ex: getters and setters)
38+
"esnext" : false, // true: Allow ES.next (ES6) syntax (ex: `const`)
39+
"moz" : false, // true: Allow Mozilla specific syntax (extends and overrides esnext features)
40+
"evil" : false, // true: Tolerate use of `eval` and `new Function()`
41+
"expr" : true, // true: Tolerate `ExpressionStatement` as Programs
42+
"funcscope" : false, // true: Tolerate defining variables inside control statements"
43+
"globalstrict" : false, // true: Allow global "use strict" (also enables 'strict')
44+
"iterator" : false, // true: Tolerate using the `__iterator__` property
45+
"lastsemic" : false, // true: Tolerate omitting a semicolon for the last statement of a 1-line block
46+
"laxbreak" : false, // true: Tolerate possibly unsafe line breakings
47+
"laxcomma" : false, // true: Tolerate comma-first style coding
48+
"loopfunc" : false, // true: Tolerate functions being defined in loops
49+
"multistr" : false, // true: Tolerate multi-line strings
50+
"proto" : false, // true: Tolerate using the `__proto__` property
51+
"scripturl" : false, // true: Tolerate script-targeted URLs
52+
"smarttabs" : false, // true: Tolerate mixed tabs/spaces when used for alignment
53+
"shadow" : false, // true: Allows re-define variables later in code e.g. `var x=1; x=2;`
54+
"sub" : false, // true: Tolerate using `[]` notation when it can still be expressed in dot notation
55+
"supernew" : false, // true: Tolerate `new function () { ... };` and `new Object;`
56+
"validthis" : false, // true: Tolerate using this in a non-constructor function
57+
58+
// Environments
59+
"browser" : false, // Web Browser (window, document, etc)
60+
"couch" : false, // CouchDB
61+
"devel" : false, // Development/debugging (alert, confirm, etc)
62+
"dojo" : false, // Dojo Toolkit
63+
"jquery" : false, // jQuery
64+
"mocha" : false, // Mocha
65+
"mootools" : false, // MooTools
66+
"node" : true, // Node.js
67+
"nonstandard" : true, // Widely adopted globals (escape, unescape, etc)
68+
"prototypejs" : false, // Prototype and Scriptaculous
69+
"rhino" : false, // Rhino
70+
"worker" : false, // Web Workers
71+
"wsh" : false, // Windows Scripting Host
72+
"yui" : false, // Yahoo User Interface
73+
74+
// Legacy
75+
"nomen" : false, // true: Prohibit dangling `_` in variables
76+
"onevar" : false, // true: Allow only one `var` statement per function
77+
"passfail" : false, // true: Stop on first error
78+
"white" : false, // true: Check against strict whitespace and indentation rules
79+
80+
// Custom Globals
81+
"globals": {
82+
}
83+
84+
}
85+

.npmignore

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
**/*~
2+
**/._*
3+
**/.DS_Store
4+
npm-debug.log
5+
/.idea
6+
/test
7+
/.*

.yo-rc.json

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"@bigstickcarpet/generator-npm": {
3+
"env": {
4+
"node": true,
5+
"browser": false,
6+
"yeoman": false,
7+
"cordova": false
8+
},
9+
"githubUsername": "BigstickCarpet",
10+
"tests": false
11+
}
12+
}

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2015 James Messinger
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in
13+
all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE.

README.md

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
sourcemapify
2+
============================
3+
#### source-map plugin for Browserify
4+
5+
[![Dependencies](https://img.shields.io/david/BigstickCarpet/sourcemapify.svg)](https://david-dm.org/BigstickCarpet/sourcemapify)
6+
[![npm](http://img.shields.io/npm/v/sourcemapify.svg)](https://www.npmjs.com/package/sourcemapify)
7+
[![License](https://img.shields.io/npm/l/sourcemapify.svg)](LICENSE)
8+
9+
10+
The default sourcemap that Browserify generates uses paths that are relative to the current directory, which may not always be what you want. This plugin lets you change the relative path, or use absolute paths.
11+
12+
This plugin was inspired by [browserify-sourcemap-root-transform](https://github.com/blackberry/browserify-sourcemap-root-transform), so check that one out if this one doesn't meet your needs.
13+
14+
15+
Installation
16+
--------------------------
17+
Install using [npm](https://docs.npmjs.com/getting-started/what-is-npm):
18+
19+
```bash
20+
npm install sourcemapify
21+
```
22+
23+
24+
Usage
25+
--------------------------
26+
### Command Line
27+
Use Browserify's sub-argument command-line syntax, like this:
28+
29+
```bash
30+
browserify -p [ sourcemapify --root "../../" ] --debug
31+
```
32+
33+
### Browserify API
34+
Use the plugin programmatically like this: [full example](test/api.js)
35+
36+
```javascript
37+
var browserify = require('browserify');
38+
var sourcemapify = require('sourcemapify');
39+
40+
browserify({debug: true})
41+
.plugin(sourcemapify, {base: 'www/js'})
42+
.bundle()
43+
.pipe(fs.createWriteStream('www/js/bundle.js', 'utf8'));
44+
```
45+
46+
47+
Options
48+
--------------------------
49+
There's only a couple options right now, but I plan to add more in the future.
50+
51+
#### `root` (string)
52+
The root path for all files in the source map. It can be an absolute or relative path. This string will be prepended as-is to each file path.
53+
54+
#### `base` (string)
55+
The base path of the bundle (i.e. the bundle file's directory, relative to cwd). This path will be used to determine the relative path of each file. It can be an absolute or relative path.

lib/index.js

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/* jshint -W040 */
2+
'use strict';
3+
4+
var path = require('path'),
5+
through = require('through');
6+
7+
module.exports = sourcemapify;
8+
9+
/**
10+
* Transforms the browserify sourcemap
11+
*
12+
* @param browserify
13+
* @param options
14+
*/
15+
function sourcemapify(browserify, options) {
16+
options = options || browserify._options || {};
17+
18+
// Create a stream to transform the sourcemap
19+
var transformStream = through(write, end);
20+
21+
function write(data) {
22+
if (options.base) {
23+
// Determine the relative path
24+
// from the bundle file's directory to the source file
25+
var base = path.resolve(process.cwd(), options.base);
26+
data.sourceFile = path.relative(base, data.file);
27+
}
28+
29+
if (options.root) {
30+
// Prepend the root path to the file path
31+
data.sourceFile = path.join(options.root, data.sourceFile);
32+
}
33+
34+
this.queue(data);
35+
}
36+
37+
function end() {
38+
this.queue(null);
39+
}
40+
41+
// Add our transform stream to Browserify's "debug" pipeline
42+
// https://github.com/substack/node-browserify#bpipeline
43+
browserify.pipeline.get('debug').push(transformStream);
44+
return this;
45+
}

0 commit comments

Comments
 (0)