validate-element-name
Advanced tools
Comparing version 0.7.1 to 1.0.0
38
cli.js
#!/usr/bin/env node | ||
'use strict'; | ||
var logSymbols = require('log-symbols'); | ||
var pkg = require('./package.json'); | ||
var validate = require('./index'); | ||
var input = process.argv[2]; | ||
var validate = require('./'); | ||
var argv = process.argv.slice(2); | ||
var input = argv[0]; | ||
function help() { | ||
console.log(pkg.description); | ||
console.log(''); | ||
console.log('Usage'); | ||
console.log(' $ validate-element-name <element-name>'); | ||
console.log(''); | ||
console.log('Example'); | ||
console.log(' $ validate-element-name s-slider'); | ||
console.log(' Valid element name 👍'); | ||
console.log([ | ||
'', | ||
' ' + pkg.description, | ||
'', | ||
' Usage', | ||
' validate-element-name <element-name>', | ||
'', | ||
' Example', | ||
' validate-element-name s-slider', | ||
' ' + logSymbols.success + ' Valid element name.' | ||
].join('\n')); | ||
} | ||
if (!input || process.argv.indexOf('-h') !== -1 || process.argv.indexOf('--help') !== -1) { | ||
if (!input || argv.indexOf('--help') !== -1) { | ||
help(); | ||
@@ -23,3 +28,3 @@ return; | ||
if (process.argv.indexOf('-v') !== -1 || process.argv.indexOf('--version') !== -1) { | ||
if (argv.indexOf('--version') !== -1) { | ||
console.log(pkg.version); | ||
@@ -32,9 +37,10 @@ return; | ||
if (res.isValid) { | ||
console.log('👍 Valid element name'); | ||
if (res.message) { | ||
console.log('\nWarning:\n' + res.message); | ||
console.log(logSymbols.success + ' Valid element name, but...'); | ||
console.log(logSymbols.warning + ' ' + res.message); | ||
} else { | ||
console.log(logSymbols.success + ' Valid element name.'); | ||
} | ||
} else { | ||
console.error('👎 Invalid element name\n\n' + res.message); | ||
console.error(logSymbols.error + ' ' + res.message); | ||
} |
@@ -20,4 +20,4 @@ 'use strict'; | ||
if (name.toLowerCase() !== name) { | ||
return 'Custom element names must be lowercase.'; | ||
if (/[A-Z]/.test(name)) { | ||
return 'Custom element names must not contain uppercase ASCII characters.'; | ||
} | ||
@@ -45,3 +45,3 @@ | ||
} | ||
}; | ||
} | ||
@@ -48,0 +48,0 @@ function hasWarning(name) { |
{ | ||
"name": "validate-element-name", | ||
"version": "0.7.1", | ||
"version": "1.0.0", | ||
"description": "Validate the name of a custom element", | ||
"license": "MIT", | ||
"repository": "sindresorhus/validate-element-name", | ||
"bin": { | ||
"validate-element-name": "cli.js" | ||
}, | ||
"author": { | ||
@@ -15,2 +12,5 @@ "name": "Sindre Sorhus", | ||
}, | ||
"bin": { | ||
"validate-element-name": "cli.js" | ||
}, | ||
"engines": { | ||
@@ -46,3 +46,4 @@ "node": ">=0.10.0" | ||
"dependencies": { | ||
"ncname": "^0.1.0" | ||
"log-symbols": "^1.0.0", | ||
"ncname": "^1.0.0" | ||
}, | ||
@@ -49,0 +50,0 @@ "devDependencies": { |
@@ -11,3 +11,3 @@ # validate-element-name [![Build Status](https://travis-ci.org/sindresorhus/validate-element-name.svg?branch=master)](https://travis-ci.org/sindresorhus/validate-element-name) | ||
```bash | ||
```sh | ||
$ npm install --save validate-element-name | ||
@@ -31,19 +31,15 @@ ``` | ||
You can also use it as a CLI app by installing it globally: | ||
```bash | ||
```sh | ||
$ npm install --global validate-element-name | ||
``` | ||
#### Usage | ||
```bash | ||
```sh | ||
$ validate-element-name --help | ||
Usage | ||
$ validate-element-name <element-name> | ||
Usage | ||
validate-element-name <element-name> | ||
Example | ||
$ validate-element-name s-slider | ||
👍 Valid element name | ||
Example | ||
validate-element-name s-slider | ||
✔︎ Valid element name. | ||
``` | ||
@@ -54,2 +50,2 @@ | ||
[MIT](http://opensource.org/licenses/MIT) © [Sindre Sorhus](http://sindresorhus.com) | ||
MIT © [Sindre Sorhus](http://sindresorhus.com) |
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
114
1
5498
2
49
+ Addedlog-symbols@^1.0.0
+ Addedansi-regex@2.1.1(transitive)
+ Addedansi-styles@2.2.1(transitive)
+ Addedchalk@1.1.3(transitive)
+ Addedescape-string-regexp@1.0.5(transitive)
+ Addedhas-ansi@2.0.0(transitive)
+ Addedlog-symbols@1.0.2(transitive)
+ Addedncname@1.0.0(transitive)
+ Addedstrip-ansi@3.0.1(transitive)
+ Addedsupports-color@2.0.0(transitive)
+ Addedxml-char-classes@1.0.0(transitive)
- Removedncname@0.1.2(transitive)
- Removedxml-char-classes@0.1.0(transitive)
Updatedncname@^1.0.0