├── .esformatter ├── .eslintrc.json ├── .gitignore ├── .travis.yml ├── .vscode └── settings.json ├── README.md ├── index.js ├── package.json └── test ├── resources ├── index.html └── package.json └── test.js /.esformatter: -------------------------------------------------------------------------------- 1 | { 2 | "root": true, 3 | "indent": { 4 | "value": " ", 5 | "alignComments": true, 6 | "ArrayExpression": 1, 7 | "ArrayPattern": 1, 8 | "ArrowFunctionExpression": 1, 9 | "AssignmentExpression": 1, 10 | "AssignmentExpression.BinaryExpression": 1, 11 | "AssignmentExpression.LogicalExpression": 1, 12 | "AssignmentExpression.UnaryExpression": 1, 13 | "CallExpression": 1, 14 | "CallExpression.BinaryExpression": 1, 15 | "CallExpression.LogicalExpression": 1, 16 | "CallExpression.UnaryExpression": 1, 17 | "CatchClause": 1, 18 | "ConditionalExpression": 1, 19 | "CommentInsideEmptyBlock": 1, 20 | "ClassDeclaration": 1, 21 | "ClassExpression": 1, 22 | "DoWhileStatement": 1, 23 | "ForInStatement": 1, 24 | "ForOfStatement": 1, 25 | "ForStatement": 1, 26 | "FunctionDeclaration": 1, 27 | "FunctionExpression": 1, 28 | "IfStatement": 1, 29 | "MemberExpression": 1, 30 | "MultipleVariableDeclaration": 1, 31 | "NewExpression": 1, 32 | "ObjectExpression": 1, 33 | "ObjectExpression.BinaryExpression": 1, 34 | "ObjectExpression.LogicalExpression": 1, 35 | "ObjectExpression.UnaryExpression": 1, 36 | "ObjectPattern": 1, 37 | "ParameterList": 1, 38 | "ReturnStatement": 1, 39 | "SingleVariableDeclaration": 0, 40 | "SwitchCase": 1, 41 | "SwitchStatement": 1, 42 | "TopLevelFunctionBlock": 1, 43 | "TryStatement": 1, 44 | "VariableDeclaration.BinaryExpression": 1, 45 | "VariableDeclaration.LogicalExpression": 1, 46 | "VariableDeclaration.UnaryExpression": 1, 47 | "WhileStatement": 1 48 | }, 49 | "lineBreak": { 50 | "value": "\n", 51 | 52 | "before": { 53 | "AssignmentExpression" : ">=1", 54 | "AssignmentOperator": 0, 55 | "AssignmentPattern" : 0, 56 | "ArrayPatternOpening": 0, 57 | "ArrayPatternClosing": 0, 58 | "ArrayPatternComma": 0, 59 | "ArrowFunctionExpressionArrow": 0, 60 | "ArrowFunctionExpressionOpeningBrace": 0, 61 | "ArrowFunctionExpressionClosingBrace": ">=1", 62 | "BlockStatement" : 0, 63 | "BreakKeyword": ">=1", 64 | "CallExpression" : -1, 65 | "CallExpressionOpeningParentheses" : 0, 66 | "CallExpressionClosingParentheses" : -1, 67 | "ClassDeclaration" : ">=1", 68 | "ClassExpression" : ">=1", 69 | "ClassOpeningBrace" : 0, 70 | "ClassClosingBrace" : ">=1", 71 | "ConditionalExpression" : ">=1", 72 | "CatchOpeningBrace" : 0, 73 | "CatchClosingBrace" : ">=1", 74 | "CatchKeyword": 0, 75 | "DeleteOperator" : ">=1", 76 | "DoWhileStatement" : ">=1", 77 | "DoWhileStatementOpeningBrace" : 0, 78 | "DoWhileStatementClosingBrace" : ">=1", 79 | "EndOfFile" : -1, 80 | "EmptyStatement" : -1, 81 | "FinallyKeyword" : -1, 82 | "FinallyOpeningBrace" : 0, 83 | "FinallyClosingBrace" : ">=1", 84 | "ForInStatement" : ">=1", 85 | "ForInStatementExpressionOpening" : 0, 86 | "ForInStatementExpressionClosing" : 0, 87 | "ForInStatementOpeningBrace" : 0, 88 | "ForInStatementClosingBrace" : ">=1", 89 | "ForOfStatement" : ">=1", 90 | "ForOfStatementExpressionOpening" : 0, 91 | "ForOfStatementExpressionClosing" : 0, 92 | "ForOfStatementOpeningBrace" : 0, 93 | "ForOfStatementClosingBrace" : ">=1", 94 | "ForStatement" : ">=1", 95 | "ForStatementExpressionOpening" : 0, 96 | "ForStatementExpressionClosing" : "<2", 97 | "ForStatementOpeningBrace" : 0, 98 | "ForStatementClosingBrace" : ">=1", 99 | "FunctionExpression" : -1, 100 | "FunctionExpressionOpeningBrace" : 0, 101 | "FunctionExpressionClosingBrace" : ">=1", 102 | "FunctionDeclaration" : ">=1", 103 | "FunctionDeclarationOpeningBrace" : 0, 104 | "FunctionDeclarationClosingBrace" : ">=1", 105 | "IIFEClosingParentheses" : 0, 106 | "IfStatement" : ">=1", 107 | "IfStatementOpeningBrace" : 0, 108 | "IfStatementClosingBrace" : ">=1", 109 | "ElseIfStatement" : 0, 110 | "ElseIfStatementOpeningBrace" : 0, 111 | "ElseIfStatementClosingBrace" : ">=1", 112 | "ElseStatement" : 0, 113 | "ElseStatementOpeningBrace" : 0, 114 | "ElseStatementClosingBrace" : ">=1", 115 | "LogicalExpression" : -1, 116 | "MethodDefinition": ">=1", 117 | "MemberExpressionOpening": 0, 118 | "MemberExpressionClosing": "<2", 119 | "MemberExpressionPeriod": -1, 120 | "ObjectExpressionClosingBrace" : ">=1", 121 | "ObjectPatternOpeningBrace": 0, 122 | "ObjectPatternClosingBrace": 0, 123 | "ObjectPatternComma": 0, 124 | "Property" : ">=1", 125 | "PropertyValue" : 0, 126 | "ReturnStatement" : -1, 127 | "SwitchOpeningBrace" : 0, 128 | "SwitchClosingBrace" : ">=1", 129 | "SwitchCaseColon": 0, 130 | "ThisExpression" : -1, 131 | "ThrowStatement" : ">=1", 132 | "TryKeyword": -1, 133 | "TryOpeningBrace" : 0, 134 | "TryClosingBrace" : ">=1", 135 | "VariableName" : ">=1", 136 | "VariableValue" : 0, 137 | "VariableDeclaration" : ">=1", 138 | "VariableDeclarationSemiColon" : 0, 139 | "VariableDeclarationWithoutInit" : ">=1", 140 | "WhileStatement" : ">=1", 141 | "WhileStatementOpeningBrace" : 0, 142 | "WhileStatementClosingBrace" : ">=1" 143 | }, 144 | 145 | "after": { 146 | "AssignmentExpression" : ">=1", 147 | "AssignmentOperator" : 0, 148 | "AssignmentPattern" : 0, 149 | "ArrayPatternOpening": 0, 150 | "ArrayPatternClosing": 0, 151 | "ArrayPatternComma": 0, 152 | "ArrowFunctionExpressionArrow": 0, 153 | "ArrowFunctionExpressionOpeningBrace": ">=1", 154 | "ArrowFunctionExpressionClosingBrace": -1, 155 | "BlockStatement" : 0, 156 | "BreakKeyword": -1, 157 | "CallExpression" : -1, 158 | "CallExpressionOpeningParentheses" : -1, 159 | "CallExpressionClosingParentheses" : -1, 160 | "ClassDeclaration" : ">=1", 161 | "ClassExpression" : ">=1", 162 | "ClassOpeningBrace" : ">=1", 163 | "ClassClosingBrace" : ">=1", 164 | "CatchOpeningBrace" : ">=1", 165 | "CatchClosingBrace" : ">=0", 166 | "CatchKeyword": 0, 167 | "ConditionalExpression" : ">=1", 168 | "DeleteOperator" : ">=1", 169 | "DoWhileStatement" : ">=1", 170 | "DoWhileStatementOpeningBrace" : ">=1", 171 | "DoWhileStatementClosingBrace" : 0, 172 | "EmptyStatement" : -1, 173 | "FinallyKeyword" : -1, 174 | "FinallyOpeningBrace" : ">=1", 175 | "FinallyClosingBrace" : ">=1", 176 | "ForInStatement" : ">=1", 177 | "ForInStatementExpressionOpening" : "<2", 178 | "ForInStatementExpressionClosing" : -1, 179 | "ForInStatementOpeningBrace" : ">=1", 180 | "ForInStatementClosingBrace" : ">=1", 181 | "ForOfStatement" : ">=1", 182 | "ForOfStatementExpressionOpening" : "<2", 183 | "ForOfStatementExpressionClosing" : -1, 184 | "ForOfStatementOpeningBrace" : ">=1", 185 | "ForOfStatementClosingBrace" : ">=1", 186 | "ForStatement" : ">=1", 187 | "ForStatementExpressionOpening" : "<2", 188 | "ForStatementExpressionClosing" : -1, 189 | "ForStatementOpeningBrace" : ">=1", 190 | "ForStatementClosingBrace" : ">=1", 191 | "FunctionExpression" : ">=1", 192 | "FunctionExpressionOpeningBrace" : ">=1", 193 | "FunctionExpressionClosingBrace" : -1, 194 | "FunctionDeclaration" : ">=1", 195 | "FunctionDeclarationOpeningBrace" : ">=1", 196 | "FunctionDeclarationClosingBrace" : ">=1", 197 | "IIFEOpeningParentheses" : 0, 198 | "IfStatement" : ">=1", 199 | "IfStatementOpeningBrace" : ">=1", 200 | "IfStatementClosingBrace" : ">=1", 201 | "ElseIfStatement" : ">=1", 202 | "ElseIfStatementOpeningBrace" : ">=1", 203 | "ElseIfStatementClosingBrace" : ">=1", 204 | "ElseStatement" : ">=1", 205 | "ElseStatementOpeningBrace" : ">=1", 206 | "ElseStatementClosingBrace" : ">=1", 207 | "LogicalExpression" : -1, 208 | "MethodDefinition": ">=1", 209 | "MemberExpressionOpening": "<2", 210 | "MemberExpressionClosing": "<2", 211 | "MemberExpressionPeriod": 0, 212 | "ObjectExpressionOpeningBrace" : ">=1", 213 | "ObjectPatternOpeningBrace": 0, 214 | "ObjectPatternClosingBrace": 0, 215 | "ObjectPatternComma": 0, 216 | "Property" : 0, 217 | "PropertyName" : 0, 218 | "ReturnStatement" : -1, 219 | "SwitchOpeningBrace" : ">=1", 220 | "SwitchClosingBrace" : ">=1", 221 | "SwitchCaseColon": ">=1", 222 | "ThisExpression" : 0, 223 | "ThrowStatement" : ">=1", 224 | "TryKeyword": -1, 225 | "TryOpeningBrace" : ">=1", 226 | "TryClosingBrace" : 0, 227 | "VariableValue" : -1, 228 | "VariableDeclaration" : ">=1", 229 | "VariableDeclarationSemiColon" : ">=1", 230 | "WhileStatement" : ">=1", 231 | "WhileStatementOpeningBrace" : ">=1", 232 | "WhileStatementClosingBrace" : ">=1" 233 | } 234 | }, 235 | 236 | 237 | "whiteSpace": { 238 | "value": " ", 239 | "removeTrailing" : 1, 240 | 241 | "before": { 242 | "AssignmentPattern" : 1, 243 | "ArrayExpressionOpening" : 0, 244 | "ArrayExpressionClosing" : 0, 245 | "ArrayExpressionComma" : 0, 246 | "ArrayPatternOpening": 1, 247 | "ArrayPatternClosing": 0, 248 | "ArrayPatternComma": 0, 249 | "ArrowFunctionExpressionArrow": 1, 250 | "ArrowFunctionExpressionOpeningBrace": 1, 251 | "ArrowFunctionExpressionClosingBrace": 0, 252 | "ArgumentComma" : 0, 253 | "ArgumentList" : 0, 254 | "AssignmentOperator" : 1, 255 | "BinaryExpression": 0, 256 | "BinaryExpressionOperator" : 1, 257 | "BlockComment" : 1, 258 | "CallExpression" : -1, 259 | "CallExpressionOpeningParentheses" : 0, 260 | "CallExpressionClosingParentheses" : -1, 261 | "CatchParameterList" : 0, 262 | "CatchOpeningBrace" : 1, 263 | "CatchClosingBrace" : 1, 264 | "CatchKeyword" : 1, 265 | "CommaOperator" : 0, 266 | "ClassOpeningBrace" : 1, 267 | "ClassClosingBrace" : 1, 268 | "ConditionalExpressionConsequent" : 1, 269 | "ConditionalExpressionAlternate" : 1, 270 | "DoWhileStatementOpeningBrace" : 1, 271 | "DoWhileStatementClosingBrace" : 1, 272 | "DoWhileStatementConditional" : 1, 273 | "EmptyStatement" : 0, 274 | "ExpressionClosingParentheses" : 0, 275 | "FinallyKeyword" : -1, 276 | "FinallyOpeningBrace" : 1, 277 | "FinallyClosingBrace" : 1, 278 | "ForInStatement" : 1, 279 | "ForInStatementExpressionOpening" : 1, 280 | "ForInStatementExpressionClosing" : 0, 281 | "ForInStatementOpeningBrace" : 1, 282 | "ForInStatementClosingBrace" : 1, 283 | "ForOfStatement" : 1, 284 | "ForOfStatementExpressionOpening" : 1, 285 | "ForOfStatementExpressionClosing" : 0, 286 | "ForOfStatementOpeningBrace" : 1, 287 | "ForOfStatementClosingBrace" : 1, 288 | "ForStatement" : 1, 289 | "ForStatementExpressionOpening" : 1, 290 | "ForStatementExpressionClosing" : 0, 291 | "ForStatementOpeningBrace" : 1, 292 | "ForStatementClosingBrace" : 1, 293 | "ForStatementSemicolon" : 0, 294 | "FunctionDeclarationOpeningBrace" : 1, 295 | "FunctionDeclarationClosingBrace" : 1, 296 | "FunctionExpressionOpeningBrace" : 1, 297 | "FunctionExpressionClosingBrace" : 1, 298 | "FunctionGeneratorAsterisk": 0, 299 | "FunctionName" : 1, 300 | "IIFEClosingParentheses" : 0, 301 | "IfStatementConditionalOpening" : 1, 302 | "IfStatementConditionalClosing" : 0, 303 | "IfStatementOpeningBrace" : 1, 304 | "IfStatementClosingBrace" : 1, 305 | "ModuleSpecifierClosingBrace": 0, 306 | "ElseStatementOpeningBrace" : 1, 307 | "ElseStatementClosingBrace" : 1, 308 | "ElseIfStatementOpeningBrace" : 1, 309 | "ElseIfStatementClosingBrace" : 1, 310 | "LineComment" : 1, 311 | "LogicalExpressionOperator" : 1, 312 | "MemberExpressionOpening": 0, 313 | "MemberExpressionClosing": 0, 314 | "MemberExpressionPeriod": 0, 315 | "ObjectExpressionOpeningBrace": -1, 316 | "ObjectExpressionClosingBrace": 0, 317 | "ObjectPatternOpeningBrace": 1, 318 | "ObjectPatternClosingBrace": 0, 319 | "ObjectPatternComma": 0, 320 | "Property" : 1, 321 | "PropertyName" : 1, 322 | "PropertyValue" : 1, 323 | "ParameterComma" : 0, 324 | "ParameterList" : 0, 325 | "SwitchDiscriminantOpening" : 1, 326 | "SwitchDiscriminantClosing" : 0, 327 | "SwitchCaseColon": 0, 328 | "ThrowKeyword": 1, 329 | "TryKeyword": -1, 330 | "TryOpeningBrace" : 1, 331 | "TryClosingBrace" : 1, 332 | "UnaryExpressionOperator": 0, 333 | "VariableName" : 1, 334 | "VariableValue" : 1, 335 | "VariableDeclarationSemiColon" : 0, 336 | "WhileStatementConditionalOpening" : 1, 337 | "WhileStatementConditionalClosing" : 0, 338 | "WhileStatementOpeningBrace" : 1, 339 | "WhileStatementClosingBrace" : 1 340 | }, 341 | 342 | "after": { 343 | "AssignmentPattern" : 1, 344 | "ArrayExpressionOpening" : 0, 345 | "ArrayExpressionClosing" : 0, 346 | "ArrayExpressionComma" : 1, 347 | "ArrayPatternOpening": 0, 348 | "ArrayPatternClosing": 1, 349 | "ArrayPatternComma": 1, 350 | "ArrowFunctionExpressionArrow": 1, 351 | "ArrowFunctionExpressionOpeningBrace": 0, 352 | "ArrowFunctionExpressionClosingBrace": 0, 353 | "ArgumentComma" : 1, 354 | "ArgumentList" : 0, 355 | "AssignmentOperator" : 1, 356 | "BinaryExpression": 0, 357 | "BinaryExpressionOperator" : 1, 358 | "BlockComment" : 1, 359 | "CallExpression" : -1, 360 | "CallExpressionOpeningParentheses" : -1, 361 | "CallExpressionClosingParentheses" : -1, 362 | "CatchParameterList" : 0, 363 | "CatchOpeningBrace" : 1, 364 | "CatchClosingBrace" : 1, 365 | "CatchKeyword" : 1, 366 | "ClassOpeningBrace" : 1, 367 | "ClassClosingBrace" : 1, 368 | "CommaOperator" : 1, 369 | "ConditionalExpressionConsequent" : 1, 370 | "ConditionalExpressionTest" : 1, 371 | "DoWhileStatementOpeningBrace" : 1, 372 | "DoWhileStatementClosingBrace" : 1, 373 | "DoWhileStatementBody" : 1, 374 | "EmptyStatement" : 0, 375 | "ExpressionOpeningParentheses" : 0, 376 | "FinallyKeyword" : -1, 377 | "FinallyOpeningBrace" : 1, 378 | "FinallyClosingBrace" : 1, 379 | "ForInStatement" : 1, 380 | "ForInStatementExpressionOpening" : 0, 381 | "ForInStatementExpressionClosing" : 1, 382 | "ForInStatementOpeningBrace" : 1, 383 | "ForInStatementClosingBrace" : 1, 384 | "ForOfStatement" : 1, 385 | "ForOfStatementExpressionOpening" : 0, 386 | "ForOfStatementExpressionClosing" : 1, 387 | "ForOfStatementOpeningBrace" : 1, 388 | "ForOfStatementClosingBrace" : 1, 389 | "ForStatement" : 1, 390 | "ForStatementExpressionOpening" : 0, 391 | "ForStatementExpressionClosing" : 1, 392 | "ForStatementClosingBrace" : 1, 393 | "ForStatementOpeningBrace" : 1, 394 | "ForStatementSemicolon" : 1, 395 | "FunctionReservedWord": 0, 396 | "FunctionName" : 0, 397 | "FunctionExpressionOpeningBrace" : 1, 398 | "FunctionExpressionClosingBrace" : 0, 399 | "FunctionDeclarationOpeningBrace" : 1, 400 | "FunctionDeclarationClosingBrace" : 1, 401 | "IIFEOpeningParentheses" : 0, 402 | "IfStatementConditionalOpening" : 0, 403 | "IfStatementConditionalClosing" : 1, 404 | "IfStatementOpeningBrace" : 1, 405 | "IfStatementClosingBrace" : 1, 406 | "ModuleSpecifierOpeningBrace": 0, 407 | "ElseStatementOpeningBrace" : 1, 408 | "ElseStatementClosingBrace" : 1, 409 | "ElseIfStatementOpeningBrace" : 1, 410 | "ElseIfStatementClosingBrace" : 1, 411 | "MemberExpressionClosing": 0, 412 | "MemberExpressionOpening": 0, 413 | "MemberExpressionPeriod": 0, 414 | "MethodDefinitionName": 0, 415 | "LogicalExpressionOperator" : 1, 416 | "ObjectExpressionOpeningBrace": 0, 417 | "ObjectExpressionClosingBrace": 0, 418 | "ObjectPatternOpeningBrace": 0, 419 | "ObjectPatternClosingBrace": 0, 420 | "ObjectPatternComma": 1, 421 | "Property" : 0, 422 | "PropertyName" : 0, 423 | "PropertyValue" : 0, 424 | "ParameterComma" : 1, 425 | "ParameterList" : 0, 426 | "SwitchDiscriminantOpening" : 0, 427 | "SwitchDiscriminantClosing" : 1, 428 | "ThrowKeyword": 1, 429 | "TryKeyword": -1, 430 | "TryOpeningBrace" : 1, 431 | "TryClosingBrace" : 1, 432 | "UnaryExpressionOperator": 0, 433 | "VariableName" : 1, 434 | "VariableValue" : 0, 435 | "VariableDeclarationSemiColon" : 0, 436 | "WhileStatementConditionalOpening" : 0, 437 | "WhileStatementConditionalClosing" : 1, 438 | "WhileStatementOpeningBrace" : 1, 439 | "WhileStatementClosingBrace" : 1 440 | } 441 | }, 442 | "quotes": { 443 | "type": "single", 444 | "avoidEscape": false 445 | }, 446 | "plugins": [ 447 | "esformatter-braces", 448 | "esformatter-dot-notation", 449 | "esformatter-literal-notation", 450 | "esformatter-quotes" 451 | ] 452 | } 453 | -------------------------------------------------------------------------------- /.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "parserOptions":{ 3 | "ecmaVersion": 6, 4 | "sourceType": "module", 5 | "ecmaFeatures": { 6 | "globalReturn": true, 7 | "impliedStrict": false, 8 | "jsx": false, 9 | "experimentalObjectRestSpread": true 10 | } 11 | }, 12 | "env": { 13 | "shared-node-browser": true, 14 | "browser": true, 15 | "commonjs": true, 16 | "node": true, 17 | "es6": true, 18 | "mocha": true, 19 | "jquery": true 20 | }, 21 | "rules": { 22 | "comma-dangle": [2, "never"], 23 | "no-cond-assign": [2, "except-parens"], 24 | "no-console": 0, 25 | "no-constant-condition": 1, 26 | "no-control-regex": 2, 27 | "no-debugger": 2, 28 | "no-dupe-args": 2, 29 | "no-dupe-keys": 2, 30 | "no-duplicate-case": 2, 31 | "no-empty-character-class": 1, 32 | "no-empty": 1, 33 | "no-ex-assign": 2, 34 | "no-extra-boolean-cast": 1, 35 | "no-extra-parens": [1, "functions"], 36 | "no-extra-semi": 2, 37 | "no-func-assign": 2, 38 | "no-inner-declarations": [1, "functions"], 39 | "no-invalid-regexp": 2, 40 | "no-irregular-whitespace": 1, 41 | "no-negated-in-lhs": 2, 42 | "no-obj-calls": 2, 43 | "no-regex-spaces": 1, 44 | "no-sparse-arrays": 2, 45 | "no-unexpected-multiline": 2, 46 | "no-unreachable": 2, 47 | "use-isnan": 2, 48 | "valid-jsdoc": 0, 49 | "valid-typeof": 2, 50 | "accessor-pairs": [1, { "getWithoutSet": true, "setWithoutGet": true }], 51 | "array-callback-return": 1, 52 | "block-scoped-var": 0, 53 | "complexity": [1, 12], 54 | "consistent-return": 0, 55 | "curly": 1, 56 | "default-case": 2, 57 | "dot-location": [1, "property"], 58 | "dot-notation": [1, { "allowKeywords": true}], 59 | "eqeqeq": 2, 60 | "guard-for-in": 0, 61 | "no-alert": 2, 62 | "no-caller": 2, 63 | "no-case-declarations": 2, 64 | "no-div-regex": 1, 65 | "no-else-return": 1, 66 | "no-empty-function": 0, 67 | "no-empty-pattern": 2, 68 | "no-eq-null": 2, 69 | "no-eval": 2, 70 | "no-extend-native": 1, 71 | "no-extra-bind": 1, 72 | "no-extra-label": 1, 73 | "no-fallthrough": 2, 74 | "no-floating-decimal": 2, 75 | "no-implicit-coercion": 0, 76 | "no-implicit-globals": 0, 77 | "no-implied-eval": 2, 78 | "no-invalid-this": 0, 79 | "no-iterator": 1, 80 | "no-labels": [2, {"allowLoop": false, "allowSwitch": false}], 81 | "no-lone-blocks": 2, 82 | "no-loop-func": 2, 83 | "no-magic-numbers": 0, 84 | "no-multi-spaces": 1, 85 | "no-multi-str": 2, 86 | "no-native-reassign": 2, 87 | "no-new-func": 2, 88 | "no-new-wrappers": 2, 89 | "no-new": 1, 90 | "no-octal-escape": 1, 91 | "no-octal": 1, 92 | "no-param-reassign": [2, {"props": false}], 93 | "no-process-env": 0, 94 | "no-proto": 2, 95 | "no-redeclare": [2, { "builtinGlobals": true }], 96 | "no-return-assign": [2, "except-parens"], 97 | "no-script-url": 2, 98 | "no-self-assign": 2, 99 | "no-self-compare": 2, 100 | "no-sequences": 2, 101 | "no-throw-literal": 2, 102 | "no-unmodified-loop-condition": 1, 103 | "no-unused-expressions": [2, { "allowShortCircuit": true, "allowTernary": false }], 104 | "no-unused-labels": 1, 105 | "no-useless-call": 1, 106 | "no-useless-concat": 1, 107 | "no-void": 2, 108 | "no-warning-comments": [1, { "terms": ["todo", "fix"], "location": "anywhere" }], 109 | "no-with": 2, 110 | "radix": [2, "as-needed"], 111 | "vars-on-top": 0, 112 | "wrap-iife": [2, "outside"], 113 | "yoda": [1, "never", { "onlyEquality": true }], 114 | "strict": [1, "safe"], 115 | "init-declarations": 0, 116 | "no-catch-shadow": 2, 117 | "no-delete-var": 2, 118 | "no-label-var": 2, 119 | "no-shadow-restricted-names": 2, 120 | "no-shadow": [2, {"builtinGlobals": false, "hoist": "functions"}], 121 | "no-undef-init": 1, 122 | "no-undef": [2, { "typeof": false }], 123 | "no-undefined": 0, 124 | "no-unused-vars": [1, { "vars": "all", "args": "none" }], 125 | "no-use-before-define": [1, {"functions": false, "classes": true}], 126 | "array-bracket-spacing": [1, "never"], 127 | "block-spacing": [1, "always"], 128 | "brace-style": [1, "1tbs", { "allowSingleLine": true }], 129 | "camelcase": [1, {"properties": "never"}], 130 | "comma-spacing": [2, {"before": false, "after": true}], 131 | "comma-style": [1, "last"], 132 | "computed-property-spacing": [1, "never"], 133 | "consistent-this": [1, "_this", "self", "ctx"], 134 | "eol-last": [1, "unix"], 135 | "func-names": 0, 136 | "func-style": [0, "expression", { "allowArrowFunctions": true }], 137 | "id-length": [2, {"min": 1, "max": 35, "properties": "never"}], 138 | "id-match": 0, 139 | "id-blacklist": 0, 140 | "indent": [1, 4, {"VariableDeclarator": 1, "SwitchCase": 1}], 141 | "jsx-quotes": 0, 142 | "key-spacing": [1, {"beforeColon": false, "afterColon": true}], 143 | "keyword-spacing": [1, {"before": true, "after": true}], 144 | "linebreak-style": [1, "unix"], 145 | "lines-around-comment": [1, { "beforeBlockComment": true, "afterBlockComment": false, "beforeLineComment": true, "afterLineComment": false, "allowBlockStart": true, "allowBlockEnd": true, "allowObjectStart": true, "allowArrayStart": false, "allowArrayEnd": false }], 146 | "max-depth": [1, 5], 147 | "max-len": [1, {"code": 300, "comments": 300, "tabWidth": 4, "ignoreUrls": true}], 148 | "max-nested-callbacks": [1, 5], 149 | "max-params": [1, 10], 150 | "max-statements": [1, 30, {"ignoreTopLevelFunctions": true}], 151 | "new-cap": [1, {"newIsCap": true, "capIsNew": true, "properties": false}], 152 | "new-parens": 1, 153 | "newline-after-var": 0, 154 | "newline-per-chained-call": 0, 155 | "no-array-constructor": 1, 156 | "no-bitwise": 0, 157 | "no-continue": 0, 158 | "no-inline-comments": 0, 159 | "no-lonely-if": 1, 160 | "no-mixed-spaces-and-tabs": 1, 161 | "no-multiple-empty-lines": [1, {"max": 2}], 162 | "no-negated-condition": 0, 163 | "no-nested-ternary": 1, 164 | "no-new-object": 1, 165 | "no-plusplus": 0, 166 | "no-restricted-syntax": [1, "WithStatement"], 167 | "no-whitespace-before-property": 1, 168 | "no-spaced-func": 1, 169 | "no-ternary": 0, 170 | "no-trailing-spaces": [1, { "skipBlankLines": true }], 171 | "no-underscore-dangle": 0, 172 | "no-unneeded-ternary": 1, 173 | "object-curly-spacing": [1, "never"], 174 | "one-var": 0, 175 | "one-var-declaration-per-line": 0, 176 | "operator-assignment": 0, 177 | "operator-linebreak": 0, 178 | "padded-blocks": 0, 179 | "quote-props": [1, "as-needed"], 180 | "quotes": [1, "single"], 181 | "require-jsdoc": 0, 182 | "semi-spacing": [2, { "before": false, "after": true }], 183 | "semi": [1, "always"], 184 | "sort-vars": 0, 185 | "sort-imports": 0, 186 | "space-before-blocks": [1, { "functions": "always", "keywords": "always", "classes": "always" }], 187 | "space-before-function-paren": [1, {"anonymous": "never", "named": "never"}], 188 | "space-in-parens": [1, "never"], 189 | "space-infix-ops": 1, 190 | "space-unary-ops": [1, { "words": true, "nonwords": false }], 191 | "spaced-comment": 0, 192 | "wrap-regex": 0 193 | } 194 | } 195 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | 3 | # Dependency 4 | node_modules 5 | 6 | build/ 7 | cache/ 8 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - "7.0" 4 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | // 将设置放入此文件中以覆盖默认值和用户设置。 2 | { 3 | "javascript.format.enable": true, 4 | "editor.formatOnSave": true, 5 | "eslint.enable": true 6 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | gulp-nw-builder 2 | ======================== 3 | 4 | [![NPM version][npm-image]][npm-url] 5 | ![][david-url] 6 | ![][travis-url] 7 | 8 | Help developers build their own `nw.js` apps for different platforms such as win, mac and linux with gulp. 9 | ## Information 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 |
Packagegulp-nw-builder
DescriptionA simple wrapper for `nw-builder`
Node Version>= 7.0
24 | 25 | ## Usage 26 | 27 | ```javascript 28 | var builder = require('gulp-nw-builder'); 29 | 30 | gulp.task('scripts', function() { 31 | return gulp.src(['./resources/**/*']) 32 | .pipe(builder({ 33 | version: '0.20.1', 34 | platforms: ['osx64'] 35 | })); 36 | }); 37 | 38 | ``` 39 | 40 | This will pass all the files into `nw-builder`, and generate the `nw.js` app. 41 | 42 | It's better you use [nw-builder](https://github.com/nwjs/nw-builder) directly, since nothing special here but a simple wrapper. 43 | 44 | ## Options 45 | 46 | All the options will be passed into `nw-builder` directly except `files`. 47 | 48 | For detail description, see: [Options](https://github.com/nwjs/nw-builder/blob/master/README.md) 49 | 50 | Additionally, `quiet: true` will disable all logging to gulp. 51 | 52 | ## LICENSE 53 | 54 | [MIT License](http://en.wikipedia.org/wiki/MIT_License) 55 | 56 | [npm-url]: https://npmjs.org/package/gulp-nw-builder 57 | [npm-image]: https://badge.fury.io/js/gulp-nw-builder.png 58 | [travis-url]:https://api.travis-ci.org/leftstick/gulp-nw-builder.svg?branch=master 59 | [david-url]:https://david-dm.org/leftstick/gulp-nw-builder.png 60 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | const NwBuilder = require('nw-builder'); 2 | const through = require('through2'); 3 | const gutil = require('gulp-util'); 4 | const PluginError = gutil.PluginError; 5 | 6 | const PLUGIN_NAME = 'gulp-nw-builder'; 7 | 8 | 9 | const gulpNodeWebkitBuilder = function(opts = {}) { 10 | 11 | const options = opts; 12 | 13 | const files = []; 14 | 15 | const stream = through.obj(function(file, encoding, next) { 16 | 17 | files.push(file.path); 18 | 19 | next(); 20 | 21 | }, function(cb) { 22 | 23 | options.files = files; 24 | 25 | const nw = new NwBuilder(options); 26 | 27 | if (!options.quiet) { 28 | nw.on('log', gutil.log); 29 | } 30 | 31 | nw.build() 32 | .then(() => { 33 | if (!options.quiet) { 34 | gutil.log('all done!'); 35 | } 36 | cb(); 37 | }) 38 | .catch(err => { 39 | this.emit('error', new PluginError(PLUGIN_NAME, 'Error occurred while building app: ' + err)); 40 | return cb(); 41 | }); 42 | 43 | }); 44 | 45 | // returning the file stream 46 | stream.resume(); 47 | return stream; 48 | }; 49 | 50 | module.exports = gulpNodeWebkitBuilder; 51 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "gulp-nw-builder", 3 | "version": "1.4.0", 4 | "description": "Help developers build their own nw.js apps for different platforms such as win, mac and linux with gulp.", 5 | "main": "index.js", 6 | "engines" : { 7 | "node" : ">=7.0.0" 8 | }, 9 | "repository": { 10 | "type": "git", 11 | "url": "https://github.com/leftstick/gulp-nw-builder.git" 12 | }, 13 | "keywords": [ 14 | "gulpplugin" 15 | ], 16 | "scripts": { 17 | "test": "mocha --reporter nyan -t 5000000" 18 | }, 19 | "author": "Howard.Zuo", 20 | "license": "MIT", 21 | "bugs": { 22 | "url": "https://github.com/leftstick/gulp-nw-builder/issues" 23 | }, 24 | "homepage": "https://github.com/leftstick/gulp-nw-builder", 25 | "dependencies": { 26 | "gulp-util": "^3.0.8", 27 | "nw-builder": "^3.1.3", 28 | "through2": "^2.0.3" 29 | }, 30 | "devDependencies": { 31 | "gulp": "^3.9.1", 32 | "mocha": "^3.2.0" 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /test/resources/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | TEST 6 | 7 | 8 | This is the test 9 | 10 | -------------------------------------------------------------------------------- /test/resources/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "test", 3 | "main": "index.html", 4 | "description": "TEST", 5 | "author": "Howard.Zuo", 6 | "version": "1.1.0", 7 | "window": { 8 | "title": "TEST", 9 | "toolbar": true, 10 | "frame": true, 11 | "position": "center", 12 | "as_desktop": true, 13 | "resizable": true 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /test/test.js: -------------------------------------------------------------------------------- 1 | const builder = require('../'); 2 | const gulp = require('gulp'); 3 | 4 | describe('gulp-nw-builder', () => { 5 | 6 | it('default test', done => { 7 | 8 | gulp.src(['test/resources/*.*']) 9 | .pipe(builder({ 10 | version: '0.20.1', 11 | platforms: [ 12 | 'osx64' 13 | ] 14 | })) 15 | .on('end', () => { 16 | done(); 17 | }) 18 | .on('error', err => { 19 | done(err); 20 | }); 21 | }); 22 | 23 | }); 24 | --------------------------------------------------------------------------------