-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
tianxiang.wly
committed
Jan 10, 2016
0 parents
commit 9c044ee
Showing
8 changed files
with
330 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
{ | ||
"env": { | ||
"node": true, | ||
"es6": true | ||
}, | ||
"rules": { | ||
"strict": [2, "global"], | ||
"no-shadow": 2, | ||
"no-shadow-restricted-names": 2, | ||
"no-unused-vars": [2, { | ||
"vars": "local", | ||
"args": "after-used" | ||
}], | ||
"no-use-before-define": 2, | ||
|
||
"comma-dangle": [2, "never"], | ||
"no-cond-assign": [0, "always"], | ||
"no-console": 0, | ||
"no-debugger": 1, | ||
"no-alert": 1, | ||
"no-constant-condition": 1, | ||
"no-dupe-keys": 2, | ||
"no-duplicate-case": 2, | ||
"no-empty": 2, | ||
"no-ex-assign": 2, | ||
"no-extra-boolean-cast": 0, | ||
"no-extra-semi": 2, | ||
"no-func-assign": 2, | ||
"no-inner-declarations": 2, | ||
"no-invalid-regexp": 2, | ||
"no-irregular-whitespace": 2, | ||
"no-obj-calls": 2, | ||
"quote-props": [2, "as-needed", { | ||
"keywords": true | ||
}], | ||
"no-sparse-arrays": 2, | ||
"no-unreachable": 2, | ||
"use-isnan": 2, | ||
"block-scoped-var": 2, | ||
|
||
"consistent-return": 2, | ||
"curly": 0, | ||
"default-case": 2, | ||
"dot-notation": [2, { | ||
"allowKeywords": true | ||
}], | ||
"eqeqeq": 2, | ||
"guard-for-in": 2, | ||
"no-caller": 2, | ||
"no-else-return": 2, | ||
"no-eq-null": 2, | ||
"no-eval": 2, | ||
"no-extend-native": 2, | ||
"no-extra-bind": 2, | ||
"no-fallthrough": 2, | ||
"no-floating-decimal": 2, | ||
"no-implied-eval": 2, | ||
"no-lone-blocks": 2, | ||
"no-loop-func": 2, | ||
"no-multi-str": 2, | ||
"no-native-reassign": 2, | ||
"no-new": 2, | ||
"no-new-func": 2, | ||
"no-new-wrappers": 2, | ||
"no-octal": 2, | ||
"no-octal-escape": 2, | ||
"no-param-reassign": 0, | ||
"no-proto": 2, | ||
"no-redeclare": 2, | ||
"no-return-assign": 2, | ||
"no-script-url": 2, | ||
"no-self-compare": 2, | ||
"no-sequences": 2, | ||
"no-throw-literal": 2, | ||
"no-with": 2, | ||
"radix": 2, | ||
"wrap-iife": [2, "any"], | ||
"yoda": 2, | ||
|
||
"indent": [0, 2], | ||
"brace-style": [2, | ||
"1tbs", { | ||
"allowSingleLine": true | ||
} | ||
], | ||
"quotes": [ | ||
2, "single", "avoid-escape" | ||
], | ||
"camelcase": [2, { | ||
"properties": "never" | ||
}], | ||
"comma-spacing": [2, { | ||
"before": false, | ||
"after": true | ||
}], | ||
"comma-style": [2, "last"], | ||
"eol-last": 2, | ||
"func-names": 0, | ||
"key-spacing": [2, { | ||
"beforeColon": false, | ||
"afterColon": true | ||
}], | ||
"new-cap": 0, | ||
"no-multiple-empty-lines": [2, { | ||
"max": 2 | ||
}], | ||
"no-nested-ternary": 2, | ||
"no-new-object": 2, | ||
"no-spaced-func": 2, | ||
"no-trailing-spaces": 2, | ||
"no-extra-parens": 2, | ||
"no-underscore-dangle": 0, | ||
"one-var": [2, "never"], | ||
"padded-blocks": [2, "never"], | ||
"semi": [2, "always"], | ||
"semi-spacing": [2, { | ||
"before": false, | ||
"after": true | ||
}], | ||
"space-after-keywords": 2, | ||
"space-before-blocks": 2, | ||
"space-before-function-paren": [2, "never"], | ||
"space-infix-ops": 2, | ||
"space-return-throw-case": 2, | ||
"spaced-comment": 2, | ||
"no-path-concat": 0 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Logs | ||
logs | ||
*.log | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
|
||
# 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 directory | ||
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
language: node_js | ||
node_js: | ||
- "stable" | ||
- "4.0.0" | ||
- "5.0.0" | ||
script: "npm run test-travis" | ||
after_script: "npm install coveralls@2.10.0 && cat ./coverage/lcov.info | coveralls" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2015 LingyuCoder | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# check-taggable | ||
|
||
[![Test coverage](https://img.shields.io/coveralls/LingyuCoder/check-taggable.svg?style=flat-square)](https://coveralls.io/r/LingyuCoder/check-taggable?branch=master) | ||
[![Build Status](https://travis-ci.org/LingyuCoder/check-taggable.png)](https://travis-ci.org/LingyuCoder/check-taggable) | ||
[![Dependency Status](https://david-dm.org/LingyuCoder/check-taggable.svg)](https://david-dm.org/LingyuCoder/check-taggable) | ||
[![devDependency Status](https://david-dm.org/LingyuCoder/check-taggable/dev-status.svg)](https://david-dm.org/LingyuCoder/check-taggable#info=devDependencies) | ||
[![NPM version](http://img.shields.io/npm/v/check-taggable.svg?style=flat-square)](http://npmjs.org/package/check-taggable) | ||
[![node](https://img.shields.io/badge/node.js-%3E=_4.0-green.svg?style=flat-square)](http://nodejs.org/download/) | ||
[![License](http://img.shields.io/npm/l/check-taggable.svg?style=flat-square)](LICENSE) | ||
[![npm download](https://img.shields.io/npm/dm/check-taggable.svg?style=flat-square)](https://npmjs.org/package/check-taggable) | ||
|
||
Check whether the tag can be used | ||
|
||
## Installation | ||
|
||
```bash | ||
$ npm install --save check-taggable | ||
``` | ||
|
||
## Usage | ||
|
||
## Test | ||
|
||
```bash | ||
$ npm run test | ||
$ npm run test-cov | ||
$ npm run test-travis | ||
``` | ||
|
||
## License | ||
|
||
The MIT License (MIT) | ||
|
||
Copyright (c) 2015 LingyuCoder | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
'use strict'; | ||
|
||
const execSync = require('child_process').execSync; | ||
const co = require('co'); | ||
|
||
module.exports = co.wrap(function*(tag, cwd) { | ||
cwd = cwd || process.cwd(); | ||
if (typeof tag !== 'string') throw Promise.reject(new TypeError('Expected tag to be a string')); | ||
if (typeof cwd !== 'string') throw Promise.reject(new TypeError('Expected cwd to be a string')); | ||
let cmdRst = ''; | ||
try { | ||
cmdRst = execSync('git tag', { | ||
cwd: cwd, | ||
stdio: 'pipe' | ||
}).toString(); | ||
} catch (e) { | ||
if (e.message.indexOf('Not a git repository') !== -1) | ||
return Promise.reject(new Error(`No git repository was found in ${cwd}`)); | ||
return Promise.reject(e); | ||
} | ||
return { | ||
success: cmdRst.split('\n').filter(v => !!v).indexOf(tag) === -1 | ||
}; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
{ | ||
"name": "check-taggable", | ||
"version": "0.0.1", | ||
"description": "Check whether the tag can be used", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "NODE_ENV=test ./node_modules/.bin/_mocha --require should --reporter spec", | ||
"test-cov": "NODE_ENV=test node ./node_modules/.bin/istanbul cover ./node_modules/.bin/_mocha -- --require should", | ||
"test-travis": "NODE_ENV=test node ./node_modules/.bin/istanbul cover ./node_modules/.bin/_mocha --report lcovonly -- --require should" | ||
}, | ||
"author": "LingyuCoder", | ||
"license": "MIT", | ||
"devDependencies": { | ||
"istanbul": "~0.4.0", | ||
"mocha": "~2.3.3", | ||
"should": "^8.0.2" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/LingyuCoder/check-taggable" | ||
}, | ||
"keywords": [], | ||
"bugs": { | ||
"url": "https://github.com/LingyuCoder/check-taggable/issues" | ||
}, | ||
"publishConfig": { | ||
"registry": "http://registry.npmjs.org/" | ||
}, | ||
"dependencies": { | ||
"co": "^4.6.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
'use strict'; | ||
|
||
require('should'); | ||
const checker = require('../index'); | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
const os = require('os'); | ||
const execSync = require('child_process').execSync; | ||
|
||
describe('check-tracked', () => { | ||
describe('success', () => { | ||
it('should resolve object with success true if tag can be used', () => { | ||
return checker('publish/success').should.be.fulfilledWith({ | ||
success: true | ||
}); | ||
}); | ||
}); | ||
describe('fail', () => { | ||
beforeEach(() => execSync('git tag -a publish/test')); | ||
afterEach(() => execSync('git tag -d publish/test')); | ||
it('should resolve object with success false if tag had been used', () => { | ||
return checker('publish/fail').should.be.fulfilledWith({ | ||
success: false | ||
}); | ||
}); | ||
}); | ||
describe('error', () => { | ||
it('should reject with an error when tag is not a string', () => { | ||
return checker({}).should.be.rejectedWith(TypeError, { | ||
message: 'Expected tag to be a string' | ||
}); | ||
}); | ||
it('should reject with an error when cwd is not a string', () => { | ||
return checker('publish/test', {}).should.be.rejectedWith(TypeError, { | ||
message: 'Expected cwd to be a string' | ||
}); | ||
}); | ||
}); | ||
}); |