From 952a521ac3ad0d0ba40fe6bdb8877d7ee4ff124a Mon Sep 17 00:00:00 2001 From: Blaine Bublitz Date: Fri, 21 Apr 2017 15:38:24 -0500 Subject: [PATCH] Scaffold: Normalize repository --- .editorconfig | 12 ++++++++++ .gitignore | 23 +++++++++---------- .jscsrc | 3 +++ .travis.yml | 10 +++++++++ appveyor.yml | 25 +++++++++++++++++++++ index.js | 5 +++-- lib/helpers.js | 13 ++++------- package.json | 60 ++++++++++++++++++++++++++++++++------------------ test/add.js | 8 +++---- test/write.js | 4 ++-- 10 files changed, 113 insertions(+), 50 deletions(-) create mode 100644 .editorconfig create mode 100644 .jscsrc create mode 100644 .travis.yml create mode 100644 appveyor.yml diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..5760be5 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,12 @@ +# http://editorconfig.org +root = true + +[*] +indent_style = space +indent_size = 2 +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true + +[*.md] +trim_trailing_whitespace = false diff --git a/.gitignore b/.gitignore index 5148e52..26513c2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,6 @@ # Logs logs *.log -npm-debug.log* # Runtime data pids @@ -14,24 +13,24 @@ lib-cov # Coverage directory used by tools like istanbul coverage -# nyc test coverage -.nyc_output - # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) .grunt -# node-waf configuration -.lock-wscript - # Compiled binary addons (http://nodejs.org/api/addons.html) build/Release -# Dependency directories +# Dependency directory +# Commenting this out is preferred by some people, see +# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git- node_modules jspm_packages -# Optional npm cache directory -.npm +# Users Environment Variables +.lock-wscript + +# Garbage files +.DS_Store -# Optional REPL history -.node_repl_history +# Generated by integration tests +test/fixtures/tmp +test/fixtures/out diff --git a/.jscsrc b/.jscsrc new file mode 100644 index 0000000..703b33f --- /dev/null +++ b/.jscsrc @@ -0,0 +1,3 @@ +{ + "preset": "gulp" +} diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..0d50ecf --- /dev/null +++ b/.travis.yml @@ -0,0 +1,10 @@ +sudo: false +language: node_js +node_js: + - '6' + - '5' + - '4' + - '0.12' + - '0.10' +after_script: + - npm run coveralls diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 0000000..625fc10 --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,25 @@ +# http://www.appveyor.com/docs/appveyor-yml +# http://www.appveyor.com/docs/lang/nodejs-iojs + +environment: + matrix: + # node.js + - nodejs_version: "0.10" + - nodejs_version: "0.12" + - nodejs_version: "4" + - nodejs_version: "5" + - nodejs_version: "6" + +install: + - ps: Install-Product node $env:nodejs_version + - npm install + +test_script: + - node --version + - npm --version + - cmd: npm test + +build: off + +# build version format +version: "{build}" diff --git a/index.js b/index.js index 0394d2d..93d5062 100644 --- a/index.js +++ b/index.js @@ -24,10 +24,11 @@ function add(file, callback) { } var state = { - path: '', //root path for the sources in the map + path: '', // Root path for the sources in the map map: null, content: file.contents.toString(), - preExistingComment: null + // TODO: handle this? + preExistingComment: null, }; helpers.addSourceMaps(file, state, callback); diff --git a/lib/helpers.js b/lib/helpers.js index e443fbf..89908b2 100644 --- a/lib/helpers.js +++ b/lib/helpers.js @@ -135,15 +135,10 @@ function mapsLoaded(file, state, callback) { names: [], mappings: '', sources: [normalizePath(file.relative)], - sourcesContent: [state.content] + sourcesContent: [state.content], }; } - // TODO: add this - // else if (preExistingComment !== null && typeof preExistingComment !== 'undefined') { - // sourceMap.preExistingComment = preExistingComment; - // } - state.map.file = normalizePath(file.relative); file.sourceMap = state.map; @@ -196,8 +191,8 @@ function createSourceMapFile(opts) { }, isSocket: function () { return false; - } - } + }, + }, }); } @@ -205,7 +200,7 @@ var needsMultiline = ['.css']; function getCommentOptions(extname) { var opts = { - multiline: (needsMultiline.indexOf(extname) !== -1) + multiline: (needsMultiline.indexOf(extname) !== -1), }; return opts; diff --git a/package.json b/package.json index 6894cba..99a3199 100644 --- a/package.json +++ b/package.json @@ -1,26 +1,29 @@ { "name": "vinyl-sourcemap", "version": "0.3.0", - "description": "Add sourcemaps to vinyl files, extracted from gulp-sourcemaps by Florian Reiterer (https://github.com/floridoo/gulp-sourcemaps)", - "main": "index.js", - "scripts": { - "test": "mocha --async-only" - }, - "keywords": [ - "vinyl", - "sourcemap", - "gulp" + "description": "Add sourcemaps to Vinyl files.", + "author": "Gulp Team (http://gulpjs.com/)", + "contributors": [ + "Robin Venneman", + "Blaine Bublitz " ], - "author": "Robin Venneman", + "repository": "gulpjs/vinyl-sourcemap", "license": "MIT", - "repository": "github:gulpjs/vinyl-sourcemap", - "devDependencies": { - "eslint": "^3.4.0", - "eslint-config-gulp": "github:robinvenneman/eslint-config-gulp", - "expect": "^1.20.2", - "mississippi": "^1.3.0", - "mocha": "^3.2.0", - "vinyl-fs": "^2.4.3" + "engines": { + "node": ">= 0.10" + }, + "main": "index.js", + "files": [ + "LICENSE", + "index.js", + "lib/" + ], + "scripts": { + "lint": "eslint index.js lib/ test/add.js test/write.js && jscs index.js test/add.js test/write.js", + "pretest": "npm run lint", + "test": "mocha --async-only", + "cover": "istanbul cover _mocha --report lcovonly", + "coveralls": "npm run cover && istanbul-coveralls" }, "dependencies": { "async": "^2.1.4", @@ -28,7 +31,22 @@ "file-normalize": "^1.1.0", "graceful-fs": "^4.1.6", "object.defaults": "^1.0.0", - "through2": "^2.0.1", - "vinyl": "^1.2.0" - } + "vinyl": "^2.0.0" + }, + "devDependencies": { + "eslint": "^1.10.3", + "eslint-config-gulp": "^2.0.0", + "expect": "^1.20.2", + "istanbul": "^0.4.3", + "istanbul-coveralls": "^1.0.3", + "jscs": "^2.4.0", + "jscs-preset-gulp": "^1.0.0", + "mississippi": "^1.3.0", + "mocha": "^3.2.0" + }, + "keywords": [ + "vinyl", + "sourcemap", + "gulp" + ] } diff --git a/test/add.js b/test/add.js index 795bb17..899d0d6 100644 --- a/test/add.js +++ b/test/add.js @@ -18,7 +18,7 @@ function makeFile() { cwd: __dirname, base: path.join(__dirname, 'assets'), path: path.join(__dirname, 'assets', 'helloworld.js'), - contents: new Buffer(sourceContent) + contents: new Buffer(sourceContent), }); } @@ -30,7 +30,7 @@ function makeSourcemap() { sourceRoot: path.join(__dirname, 'assets'), sources: ['test1.js', 'test2.js'], sourcesContent: ['console.log("line 1.1");\nconsole.log("line 1.2");\n', 'console.log("line 2.1");\nconsole.log("line 2.2");'], - version: 3 + version: 3, }; } @@ -40,7 +40,7 @@ function makeFileWithInlineSourceMap() { cwd: __dirname, base: path.join(__dirname, 'assets'), path: path.join(__dirname, 'assets', 'all.js'), - contents: new Buffer('console.log("line 1.1"),console.log("line 1.2"),console.log("line 2.1"),console.log("line 2.2");\n' + inline) + contents: new Buffer('console.log("line 1.1"),console.log("line 1.2"),console.log("line 2.1"),console.log("line 2.2");\n' + inline), }); } @@ -233,7 +233,7 @@ describe('add', function() { }); }); - it('loads external sourcemap by filename if no source mapping comment', function (done) { + it('loads external sourcemap by filename if no source mapping comment', function(done) { var file = makeFile(); file.path = file.path.replace('helloworld.js', 'helloworld2.js'); sourcemaps.add(file, function(err, data) { diff --git a/test/write.js b/test/write.js index 16bfa00..a7cf4ad 100644 --- a/test/write.js +++ b/test/write.js @@ -19,7 +19,7 @@ function makeSourceMap() { names: [], mappings: '', sources: ['helloworld.js'], - sourcesContent: [sourceContent] + sourcesContent: [sourceContent], }; } @@ -39,7 +39,7 @@ function makeNestedFile() { cwd: __dirname, base: path.join(__dirname, 'assets'), path: path.join(__dirname, 'assets', 'dir1', 'dir2', 'helloworld.js'), - contents: new Buffer(sourceContent) + contents: new Buffer(sourceContent), }); file.sourceMap = makeSourceMap(); return file;