Added vscodium

This commit is contained in:
Kristofers Solo
2022-04-28 21:17:01 +03:00
parent 837a479d82
commit d7dddc39ef
29139 changed files with 250215 additions and 45125 deletions

View File

@@ -0,0 +1,43 @@
<?xml version="1.0" encoding="utf-8"?>
<PackageManifest Version="2.0.0" xmlns="http://schemas.microsoft.com/developer/vsx-schema/2011" xmlns:d="http://schemas.microsoft.com/developer/vsx-schema-design/2011">
<Metadata>
<Identity Language="en-US" Id="lorem-ipsum" Version="1.3.1" Publisher="Tyriar" />
<DisplayName>Lorem ipsum</DisplayName>
<Description xml:space="preserve">Generates and inserts lorem ipsum text</Description>
<Tags>__web_extension</Tags>
<Categories>Other</Categories>
<GalleryFlags>Public</GalleryFlags>
<Properties>
<Property Id="Microsoft.VisualStudio.Code.Engine" Value="0.10.x" />
<Property Id="Microsoft.VisualStudio.Code.ExtensionDependencies" Value="" />
<Property Id="Microsoft.VisualStudio.Code.ExtensionPack" Value="" />
<Property Id="Microsoft.VisualStudio.Code.ExtensionKind" Value="workspace,web" />
<Property Id="Microsoft.VisualStudio.Code.LocalizedLanguages" Value="" />
<Property Id="Microsoft.VisualStudio.Services.Links.Source" Value="https://github.com/Tyriar/vscode-lorem-ipsum.git" />
<Property Id="Microsoft.VisualStudio.Services.Links.Getstarted" Value="https://github.com/Tyriar/vscode-lorem-ipsum.git" />
<Property Id="Microsoft.VisualStudio.Services.Links.GitHub" Value="https://github.com/Tyriar/vscode-lorem-ipsum.git" />
<Property Id="Microsoft.VisualStudio.Services.Links.Support" Value="https://github.com/Tyriar/vscode-lorem-ipsum/issues" />
<Property Id="Microsoft.VisualStudio.Services.Links.Learn" Value="https://github.com/Tyriar/vscode-lorem-ipsum" />
<Property Id="Microsoft.VisualStudio.Services.GitHubFlavoredMarkdown" Value="true" />
</Properties>
<License>extension/LICENSE.txt</License>
<Icon>extension/images/icon.png</Icon>
</Metadata>
<Installation>
<InstallationTarget Id="Microsoft.VisualStudio.Code"/>
</Installation>
<Dependencies/>
<Assets>
<Asset Type="Microsoft.VisualStudio.Code.Manifest" Path="extension/package.json" Addressable="true" />
<Asset Type="Microsoft.VisualStudio.Services.Content.Details" Path="extension/README.md" Addressable="true" />
<Asset Type="Microsoft.VisualStudio.Services.Content.Changelog" Path="extension/CHANGELOG.md" Addressable="true" />
<Asset Type="Microsoft.VisualStudio.Services.Content.License" Path="extension/LICENSE.txt" Addressable="true" />
<Asset Type="Microsoft.VisualStudio.Services.Icons.Default" Path="extension/images/icon.png" Addressable="true" />
</Assets>
</PackageManifest>

View File

@@ -0,0 +1,18 @@
# Change Log
## 1.3.1
- vscode.dev and github.dev support via [@Tyriar](https://github.com/Tyriar)
## 1.3.0
- Added a new dark theme-friendly icon ([#2](https://github.com/Tyriar/vscode-lorem-ipsum/issues/2)) via [@Tyriar](https://github.com/Tyriar)
- Polished readme, new gif, example on how to add a keybinding via [@Tyriar](https://github.com/Tyriar)
## 1.2.0
- Added multi-cursor support
## 1.1.0
- Added the `lorem-ipsum.multipleParagraphs` command to insert multiple paragraphs via [@jcw-](https://github.com/jcw-)
- Added 'Lorem Ipsum: ' to the start of the commands to make them more easily identifiable in the command palette via [@Tyriar](https://github.com/Tyriar)
## 1.0.0
- Initial release

View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2015, Daniel Imms (http://www.growingwiththeweb.com)
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.

View File

@@ -0,0 +1,27 @@
A tiny VS Code extension made up of a few commands that generate and insert lorem ipsum text into a text file.
To use the extension, open the command palette (<kbd>F1</kbd> or <kbd>cmd/ctrl+shift+p</kbd>, type "lorem ipsum" and select to insert either a line or paragraph.
![](https://github.com/Tyriar/vscode-lorem-ipsum/raw/HEAD/images/usage-animation.gif)
## Customization
The following commands are added:
- `lorem-ipsum.line`
- `lorem-ipsum.paragraph`
- `lorem-ipsum.multipleParagraphs`
By default they don't have keybindings, but [you can add a custom keybinding](https://code.visualstudio.com/docs/getstarted/keybindings#_advanced-customization). For example:
```json
{
"key": "ctrl+shift+l",
"command": "lorem-ipsum.paragraph",
"when": "editorTextFocus"
}
```
## Credits
- The core functionality is provided by the [lorem-ipsum npm package](https://www.npmjs.com/package/lorem-ipsum)

View File

@@ -0,0 +1,325 @@
/******/ (() => { // webpackBootstrap
/******/ var __webpack_modules__ = ([
/* 0 */,
/* 1 */
/***/ ((module) => {
"use strict";
module.exports = require("vscode");
/***/ }),
/* 2 */
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
function generator() {
var options = (arguments.length) ? arguments[0] : {}
, count = options.count || 1
, units = options.units || 'sentences'
, sentenceLowerBound = options.sentenceLowerBound || 5
, sentenceUpperBound = options.sentenceUpperBound || 15
, paragraphLowerBound = options.paragraphLowerBound || 3
, paragraphUpperBound = options.paragraphUpperBound || 7
, format = options.format || 'plain'
, words = options.words || (__webpack_require__(3).words)
, random = options.random || Math.random
, suffix = options.suffix;
if (!suffix) {
var isNode = true && module.exports;
var isReactNative = typeof product !== 'undefined' && product.navigator === 'ReactNative';
var isWindows = typeof process !== 'undefined' && 'win32' === process.platform;
if (!isReactNative && isNode && isWindows) {
suffix = '\r\n';
} else {
suffix = '\n';
}
}
units = simplePluralize(units.toLowerCase());
function randomInteger(min, max) {
return Math.floor(random() * (max - min + 1) + min);
};
function randomWord(words) {
return words[randomInteger(0, words.length - 1)];
};
function randomSentence(words, lowerBound, upperBound) {
var sentence = ''
, bounds = {min: 0, max: randomInteger(lowerBound, upperBound)};
while (bounds.min < bounds.max) {
sentence += ' ' + randomWord(words);
bounds.min++;
}
if (sentence.length) {
sentence = sentence.slice(1);
sentence = sentence.charAt(0).toUpperCase() + sentence.slice(1);
}
return sentence;
};
function randomParagraph(words, lowerBound, upperBound, sentenceLowerBound, sentenceUpperBound) {
var paragraph = ''
, bounds = {min: 0, max: randomInteger(lowerBound, upperBound)};
while (bounds.min < bounds.max) {
paragraph += '. ' + randomSentence(words, sentenceLowerBound, sentenceUpperBound);
bounds.min++;
}
if (paragraph.length) {
paragraph = paragraph.slice(2);
paragraph += '.';
}
return paragraph;
}
var iter = 0
, bounds = {min: 0, max: count}
, string = ''
, prefix = ''
, openingTag
, closingTag;
if (format === 'html') {
openingTag = '<p>';
closingTag = '</p>';
}
while (bounds.min < bounds.max) {
switch (units.toLowerCase()) {
case 'words':
string += ' ' + randomWord(words);
break;
case 'sentences':
string += '. ' + randomSentence(words, sentenceLowerBound, sentenceUpperBound);
break;
case 'paragraphs':
var nextString = randomParagraph(words, paragraphLowerBound, paragraphUpperBound, sentenceLowerBound, sentenceUpperBound);
if (format === 'html') {
nextString = openingTag + nextString + closingTag;
if (bounds.min < bounds.max - 1) {
nextString += suffix; // Each paragraph on a new line
}
} else if (bounds.min < bounds.max - 1) {
nextString += suffix + suffix; // Double-up the EOL character to make distinct paragraphs, like carriage return
}
string += nextString;
break;
}
bounds.min++;
}
if (string.length) {
var pos = 0;
if (string.indexOf('. ') === 0) {
pos = 2;
} else if (string.indexOf('.') === 0 || string.indexOf(' ') === 0) {
pos = 1;
}
string = string.slice(pos);
if (units === 'sentences') {
string += '.';
}
}
return string;
};
function simplePluralize(string) {
if (string.indexOf('s', string.length - 1) === -1) {
return string + 's';
}
return string;
}
module.exports = generator;
/***/ }),
/* 3 */
/***/ ((module) => {
var dictionary = {
words: [
'ad',
'adipisicing',
'aliqua',
'aliquip',
'amet',
'anim',
'aute',
'cillum',
'commodo',
'consectetur',
'consequat',
'culpa',
'cupidatat',
'deserunt',
'do',
'dolor',
'dolore',
'duis',
'ea',
'eiusmod',
'elit',
'enim',
'esse',
'est',
'et',
'eu',
'ex',
'excepteur',
'exercitation',
'fugiat',
'id',
'in',
'incididunt',
'ipsum',
'irure',
'labore',
'laboris',
'laborum',
'Lorem',
'magna',
'minim',
'mollit',
'nisi',
'non',
'nostrud',
'nulla',
'occaecat',
'officia',
'pariatur',
'proident',
'qui',
'quis',
'reprehenderit',
'sint',
'sit',
'sunt',
'tempor',
'ullamco',
'ut',
'velit',
'veniam',
'voluptate'
]
};
module.exports = dictionary;
/***/ })
/******/ ]);
/************************************************************************/
/******/ // The module cache
/******/ var __webpack_module_cache__ = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/ // Check if module is in cache
/******/ var cachedModule = __webpack_module_cache__[moduleId];
/******/ if (cachedModule !== undefined) {
/******/ return cachedModule.exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = __webpack_module_cache__[moduleId] = {
/******/ // no module.id needed
/******/ // no module.loaded needed
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/************************************************************************/
var __webpack_exports__ = {};
// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
(() => {
var exports = __webpack_exports__;
var vscode = __webpack_require__(1);
var loremIpsum = __webpack_require__(2);
function activate(context) {
var commands = [
vscode.commands.registerCommand('lorem-ipsum.line', generateLine),
vscode.commands.registerCommand('lorem-ipsum.paragraph', generateParagraph),
vscode.commands.registerCommand('lorem-ipsum.multipleParagraphs', generateMultipleParagraphs)
];
commands.forEach(function (command) {
context.subscriptions.push(command);
});
}
function insertText(lorem) {
var editor = vscode.window.activeTextEditor;
editor.edit(
edit => editor.selections.forEach(
selection => {
edit.delete(selection);
edit.insert(selection.start, loremIpsum(lorem));
}
)
);
}
function generateLine() {
insertText({
count: 1,
units: 'sentences'
});
}
function generateParagraph() {
insertText({
count: 1,
units: 'paragraphs'
});
}
async function generateMultipleParagraphs() {
const items = [];
for (let i = 2; i <= 10; i++) {
items.push(i.toString());
}
const count = await vscode.window.showQuickPick(items, { placeHolder: 'How many paragraphs?' });
if (!count) {
return;
}
insertText({
count: Number.parseInt(count),
units: 'paragraphs'
});
}
exports.activate = activate;
})();
var __webpack_export_target__ = exports;
for(var i in __webpack_exports__) __webpack_export_target__[i] = __webpack_exports__[i];
if(__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, "__esModule", { value: true });
/******/ })()
;
//# sourceMappingURL=extension.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"extension.js","mappings":";;;;;;;AAAA;;;;;;ACAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,+BAA+B,8BAA6B;AAC5D;AACA;;AAEA;AACA,iBAAiB,KAA6B;AAC9C;AACA;;AAEA;AACA;AACA,MAAM;AACN;AACA;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,kBAAkB;;AAElB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA,kBAAkB;;AAElB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA,gBAAgB;AAChB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,kCAAkC;AAClC;AACA,UAAU;AACV,yCAAyC;AACzC;;AAEA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA,MAAM;AACN;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;ACvIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;;;;;UCnEA;UACA;;UAEA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;;UAEA;UACA;;UAEA;UACA;UACA;;;;;;;ACtBA,aAAa,mBAAO,CAAC,CAAQ;AAC7B,iBAAiB,mBAAO,CAAC,CAAa;;AAEtC;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,GAAG;AACH;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,GAAG;AACH;;AAEA;AACA;AACA;AACA;AACA,GAAG;AACH;;AAEA;AACA;AACA,kBAAkB,SAAS;AAC3B;AACA;;AAEA,2DAA2D,qCAAqC;AAChG;AACA;AACA;;AAEA;AACA;AACA;AACA,GAAG;AACH;;AAEA,gBAAgB","sources":["../../external commonjs \"vscode\"","../.././node_modules/lorem-ipsum/lib/generator.js","../.././node_modules/lorem-ipsum/lib/dictionary.js","../../webpack/bootstrap","../.././extension.js"],"names":[],"sourceRoot":""}

View File

@@ -0,0 +1,59 @@
var vscode = require('vscode');
var loremIpsum = require('lorem-ipsum');
function activate(context) {
var commands = [
vscode.commands.registerCommand('lorem-ipsum.line', generateLine),
vscode.commands.registerCommand('lorem-ipsum.paragraph', generateParagraph),
vscode.commands.registerCommand('lorem-ipsum.multipleParagraphs', generateMultipleParagraphs)
];
commands.forEach(function (command) {
context.subscriptions.push(command);
});
}
function insertText(lorem) {
var editor = vscode.window.activeTextEditor;
editor.edit(
edit => editor.selections.forEach(
selection => {
edit.delete(selection);
edit.insert(selection.start, loremIpsum(lorem));
}
)
);
}
function generateLine() {
insertText({
count: 1,
units: 'sentences'
});
}
function generateParagraph() {
insertText({
count: 1,
units: 'paragraphs'
});
}
async function generateMultipleParagraphs() {
const items = [];
for (let i = 2; i <= 10; i++) {
items.push(i.toString());
}
const count = await vscode.window.showQuickPick(items, { placeHolder: 'How many paragraphs?' });
if (!count) {
return;
}
insertText({
count: Number.parseInt(count),
units: 'paragraphs'
});
}
exports.activate = activate;

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 136 KiB

View File

@@ -0,0 +1,11 @@
# editorconfig.org
root = true
[*]
charset = utf-8
end_of_line = lf
indent_size = 2
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true

View File

@@ -0,0 +1,124 @@
### lorem-ipsum.js
lorem-ipsum.js is a Node.js, Component.js, and React Native module for generating passages of lorem ipsum text. Lorem ipsum text is commonly used as placeholder text in publishing, graphic design, and web development.
### Using the Module (Node.js)
Install the lorem-ipsum.js module to use the library in your server-side Node.js projects.
```bash
cd ~/MyProject
npm install lorem-ipsum
```
Require the lorem-ipsum.js module and use it to generate a passage of lorem ipsum text.
```javascript
var loremIpsum = require('lorem-ipsum')
, output = loremIpsum();
```
### Using the Module (Component.js)
Install the lorem-ipsum.js module to use the library client-side.
```bash
cd ~/MyProject
component install knicklabs/lorem-ipsum.js
```
Require the lorem-ipsum.js module and use it to generate a passage of lorem ipsum text.
```javascript
var loremIpsum = require('knicklabs-lorem-ipsum.js')
, output = loremIpsum();
```
### Customizing the Output with Options (Node.js/Component.js)
You can pass options to the loremIpsum() function to fine-tune the output. The API is the same on client and server. See below:
```javascript
...
output = loremIpsum({
count: 1 // Number of words, sentences, or paragraphs to generate.
, units: 'sentences' // Generate words, sentences, or paragraphs.
, sentenceLowerBound: 5 // Minimum words per sentence.
, sentenceUpperBound: 15 // Maximum words per sentence.
, paragraphLowerBound: 3 // Minimum sentences per paragraph.
, paragraphUpperBound: 7 // Maximum sentences per paragraph.
, format: 'plain' // Plain text or html
, words: ['ad', 'dolor', ... ] // Custom word dictionary. Uses dictionary.words (in lib/dictionary.js) by default.
, random: Math.random // A PRNG function. Uses Math.random by default
, suffix: EOL // The character to insert between paragraphs. Defaults to default EOL for your OS.
});
```
### Using the CLI (Node.js)
lorem-ipsum.js includes a command line interface for generating passages of lorem ipsum text. Install the module globally to take advantage of this feature.
```bash
npm install lorem-ipsum --global
```
Execute the statement `lorem-ipsum` from your terminal to generate a passage of lorem ipsum text. You can pass arguments to the program to fine-tune the output.
```bash
lorem-ipsum --units words --count 100 --copy --format html
```
See below for a description of the arguments to the program.
<table>
<tr>
<th>Argument</th>
<th>Description</th>
</tr>
<tr>
<td>--count</td>
<td>The <strong>number</strong> of words, sentences or paragraphs to generate</td>
</tr>
<tr>
<td>--units</td>
<td>Generate <strong>words</strong>, <strong>sentences</strong> or <strong>paragraphs</strong></td>
</tr>
<tr>
<td>--copy</td>
<td><strong>Copy</strong> the output to the system clipboard</td>
</tr>
<tr>
<td>--format</td>
<td><strong>html</strong> or <strong>plain</strong> text format</td>
</tr>
</table>
You may now also use a short form when running lorem-ipsum.js from the command line. Here's some examples:
```
lorem-ipsum 1 word
```
```
lorem-ipsum 15 sentences --copy
```
```
lorem-ipsum 5 paragraphs --copy --format html
```
### Notes
The copy feature requires that you have xclip installed if you are using lorem-ipsum.js on Linux. The feature will work out of the box on Mac and Windows systems.
### License
This software is licensed under the MIT license.
Copyright (c) 2012-2018 Nickolas Kenyeres
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.

View File

@@ -0,0 +1,32 @@
#!/usr/bin/env node
var minimist = require('minimist')
, generator = require('./../lib/generator')
, clipper = require('./../lib/clipper');
var options = {}
, arguments = minimist(process.argv.slice(2))
, loremIpsum = '';
// Allow CLI user to run command with plain english. E.g. "lorem-ipsum 1 sentence" or "lorem-ipsum 3 words --copy"
var nakedArguments = arguments._;
if (nakedArguments.length >= 2) {
arguments.count = nakedArguments[0]; // Clobber count.
arguments.units = nakedArguments[1]; // Clobber units.
}
options.units = arguments.units || 'sentences';
options.count = arguments.count || 1;
options.copy = arguments.copy ? true : false;
options.format = arguments.format || 'plain';
// Generate the lorem ipsum text and print it out.
loremIpsum = generator(options);
console.log(loremIpsum);
// Copy the lorem ipsum text to the clipboard.
if (options.copy) {
clipper(loremIpsum, function(err) { err ? process.exit(1) : process.exit() });
} else {
process.exit(); // Successful exit.
}

View File

@@ -0,0 +1,15 @@
{
"name": "lorem-ipsum",
"repo": "knicklabs/lorem-ipsum.js",
"description": "Generates passages of lorem ipsum text suitable for use as placeholder copy in web pages, graphics, and more.",
"version": "1.0.2",
"keywords": [],
"dependencies": {},
"development": {},
"license": "MIT",
"main": "lib/generator.js",
"scripts": [
"lib/dictionary.js",
"lib/generator.js"
]
}

View File

@@ -0,0 +1,27 @@
var execute = require('child_process').exec;
var statement = '';
var clipper = function(text, next) {
statement = 'echo "' + text + '" | ';
switch (process.platform) {
case 'darwin':
statement = statement + 'pbcopy';
break;
case 'win32':
statement = statement + 'clip';
break;
case 'linux':
default:
statement = statement + 'xclip -selection clipboard';
}
execute(statement, function(err, stdout, stderr) {
if (err) {
next(new Error('Failed to copy data to clipboard'));
}
next(null);
});
};
module.exports = clipper;

View File

@@ -0,0 +1,68 @@
var dictionary = {
words: [
'ad',
'adipisicing',
'aliqua',
'aliquip',
'amet',
'anim',
'aute',
'cillum',
'commodo',
'consectetur',
'consequat',
'culpa',
'cupidatat',
'deserunt',
'do',
'dolor',
'dolore',
'duis',
'ea',
'eiusmod',
'elit',
'enim',
'esse',
'est',
'et',
'eu',
'ex',
'excepteur',
'exercitation',
'fugiat',
'id',
'in',
'incididunt',
'ipsum',
'irure',
'labore',
'laboris',
'laborum',
'Lorem',
'magna',
'minim',
'mollit',
'nisi',
'non',
'nostrud',
'nulla',
'occaecat',
'officia',
'pariatur',
'proident',
'qui',
'quis',
'reprehenderit',
'sint',
'sit',
'sunt',
'tempor',
'ullamco',
'ut',
'velit',
'veniam',
'voluptate'
]
};
module.exports = dictionary;

View File

@@ -0,0 +1,136 @@
function generator() {
var options = (arguments.length) ? arguments[0] : {}
, count = options.count || 1
, units = options.units || 'sentences'
, sentenceLowerBound = options.sentenceLowerBound || 5
, sentenceUpperBound = options.sentenceUpperBound || 15
, paragraphLowerBound = options.paragraphLowerBound || 3
, paragraphUpperBound = options.paragraphUpperBound || 7
, format = options.format || 'plain'
, words = options.words || require('./dictionary').words
, random = options.random || Math.random
, suffix = options.suffix;
if (!suffix) {
var isNode = typeof module !== 'undefined' && module.exports;
var isReactNative = typeof product !== 'undefined' && product.navigator === 'ReactNative';
var isWindows = typeof process !== 'undefined' && 'win32' === process.platform;
if (!isReactNative && isNode && isWindows) {
suffix = '\r\n';
} else {
suffix = '\n';
}
}
units = simplePluralize(units.toLowerCase());
function randomInteger(min, max) {
return Math.floor(random() * (max - min + 1) + min);
};
function randomWord(words) {
return words[randomInteger(0, words.length - 1)];
};
function randomSentence(words, lowerBound, upperBound) {
var sentence = ''
, bounds = {min: 0, max: randomInteger(lowerBound, upperBound)};
while (bounds.min < bounds.max) {
sentence += ' ' + randomWord(words);
bounds.min++;
}
if (sentence.length) {
sentence = sentence.slice(1);
sentence = sentence.charAt(0).toUpperCase() + sentence.slice(1);
}
return sentence;
};
function randomParagraph(words, lowerBound, upperBound, sentenceLowerBound, sentenceUpperBound) {
var paragraph = ''
, bounds = {min: 0, max: randomInteger(lowerBound, upperBound)};
while (bounds.min < bounds.max) {
paragraph += '. ' + randomSentence(words, sentenceLowerBound, sentenceUpperBound);
bounds.min++;
}
if (paragraph.length) {
paragraph = paragraph.slice(2);
paragraph += '.';
}
return paragraph;
}
var iter = 0
, bounds = {min: 0, max: count}
, string = ''
, prefix = ''
, openingTag
, closingTag;
if (format === 'html') {
openingTag = '<p>';
closingTag = '</p>';
}
while (bounds.min < bounds.max) {
switch (units.toLowerCase()) {
case 'words':
string += ' ' + randomWord(words);
break;
case 'sentences':
string += '. ' + randomSentence(words, sentenceLowerBound, sentenceUpperBound);
break;
case 'paragraphs':
var nextString = randomParagraph(words, paragraphLowerBound, paragraphUpperBound, sentenceLowerBound, sentenceUpperBound);
if (format === 'html') {
nextString = openingTag + nextString + closingTag;
if (bounds.min < bounds.max - 1) {
nextString += suffix; // Each paragraph on a new line
}
} else if (bounds.min < bounds.max - 1) {
nextString += suffix + suffix; // Double-up the EOL character to make distinct paragraphs, like carriage return
}
string += nextString;
break;
}
bounds.min++;
}
if (string.length) {
var pos = 0;
if (string.indexOf('. ') === 0) {
pos = 2;
} else if (string.indexOf('.') === 0 || string.indexOf(' ') === 0) {
pos = 1;
}
string = string.slice(pos);
if (units === 'sentences') {
string += '.';
}
}
return string;
};
function simplePluralize(string) {
if (string.indexOf('s', string.length - 1) === -1) {
return string + 's';
}
return string;
}
module.exports = generator;

View File

@@ -0,0 +1,41 @@
{
"name": "lorem-ipsum",
"version": "1.0.6",
"description": "Generates passages of lorem ipsum text suitable for use as placeholder copy in web pages, graphics, and more. Works in the browser, NodeJS, and React Native.",
"author": "Nickolas Kenyeres <nkenyeres@gmail.com> (http://knicklabs.github.com)",
"license": "MIT",
"main": "./lib/generator",
"dependencies": {
"minimist": "~1.2.0"
},
"devDependencies": {
"alea": "0.0.9",
"mocha": "^5.2.0"
},
"optionalDependencies": {},
"bin": {
"lorem-ipsum": "bin/lorem-ipsum.bin.js"
},
"scripts": {
"test": "./node_modules/mocha/bin/mocha"
},
"repository": {
"type": "git",
"url": "git://github.com/knicklabs/node-lorem-ipsum.git"
},
"keywords": [
"lorem",
"ipsum",
"placeholder",
"text",
"dummy",
"filler"
],
"engine": {
"node": ">=0.4"
}
,"_resolved": "https://registry.npmjs.org/lorem-ipsum/-/lorem-ipsum-1.0.6.tgz"
,"_integrity": "sha512-Rx4XH8X4KSDCKAVvWGYlhAfNqdUP5ZdT4rRyf0jjrvWgtViZimDIlopWNfn/y3lGM5K4uuiAoY28TaD+7YKFrQ=="
,"_from": "lorem-ipsum@1.0.6"
}

View File

@@ -0,0 +1,49 @@
/*
* Series of unit tests to test randomness of output.
*/
var assert = require('assert');
var generator = require('../lib/generator');
var random = Math.random;
/*
* Helpers
*/
function generateWords(random) {
var generator = require('./../lib/generator');
var words = [];
for (var i = 0; i < 100; i++) {
words.push(generator({
count: 1,
units: 'words',
random: random
}));
}
return words.join(', ');
}
describe('generator', function() {
it('should give us unique output using Math.random()', function() {
assert.notEqual(generateWords(null), generateWords(null));
});
it('should use a custom pseudo random number generator and still have unique output', function() {
var alea = new (require('alea'));
assert.notEqual(generateWords(alea), generateWords(alea));
});
it('should create reproducible pseudo random output by seeding a custom PNRG', function() {
var alea1 = new (require('alea'))('seed');
var alea2 = new (require('alea'))('seed');
assert.equal(generateWords(alea1), generateWords(alea2));
});
it('should create pseudo random output by using unique seeds for a custom PNRG', function () {
var alea1 = new (require('alea'))('seed');
var alea2 = new (require('alea'))('different-seed');
assert.notEqual(generateWords(alea1), generateWords(alea2));
});
});

View File

@@ -0,0 +1,8 @@
language: node_js
node_js:
- "0.8"
- "0.10"
- "0.12"
- "iojs"
before_install:
- npm install -g npm@~1.4.6

View File

@@ -0,0 +1,18 @@
This software is released under the MIT license:
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.

View File

@@ -0,0 +1,2 @@
var argv = require('../')(process.argv.slice(2));
console.log(argv);

View File

@@ -0,0 +1,245 @@
module.exports = function (args, opts) {
if (!opts) opts = {};
var flags = { bools : {}, strings : {}, unknownFn: null };
if (typeof opts['unknown'] === 'function') {
flags.unknownFn = opts['unknown'];
}
if (typeof opts['boolean'] === 'boolean' && opts['boolean']) {
flags.allBools = true;
} else {
[].concat(opts['boolean']).filter(Boolean).forEach(function (key) {
flags.bools[key] = true;
});
}
var aliases = {};
Object.keys(opts.alias || {}).forEach(function (key) {
aliases[key] = [].concat(opts.alias[key]);
aliases[key].forEach(function (x) {
aliases[x] = [key].concat(aliases[key].filter(function (y) {
return x !== y;
}));
});
});
[].concat(opts.string).filter(Boolean).forEach(function (key) {
flags.strings[key] = true;
if (aliases[key]) {
flags.strings[aliases[key]] = true;
}
});
var defaults = opts['default'] || {};
var argv = { _ : [] };
Object.keys(flags.bools).forEach(function (key) {
setArg(key, defaults[key] === undefined ? false : defaults[key]);
});
var notFlags = [];
if (args.indexOf('--') !== -1) {
notFlags = args.slice(args.indexOf('--')+1);
args = args.slice(0, args.indexOf('--'));
}
function argDefined(key, arg) {
return (flags.allBools && /^--[^=]+$/.test(arg)) ||
flags.strings[key] || flags.bools[key] || aliases[key];
}
function setArg (key, val, arg) {
if (arg && flags.unknownFn && !argDefined(key, arg)) {
if (flags.unknownFn(arg) === false) return;
}
var value = !flags.strings[key] && isNumber(val)
? Number(val) : val
;
setKey(argv, key.split('.'), value);
(aliases[key] || []).forEach(function (x) {
setKey(argv, x.split('.'), value);
});
}
function setKey (obj, keys, value) {
var o = obj;
for (var i = 0; i < keys.length-1; i++) {
var key = keys[i];
if (key === '__proto__') return;
if (o[key] === undefined) o[key] = {};
if (o[key] === Object.prototype || o[key] === Number.prototype
|| o[key] === String.prototype) o[key] = {};
if (o[key] === Array.prototype) o[key] = [];
o = o[key];
}
var key = keys[keys.length - 1];
if (key === '__proto__') return;
if (o === Object.prototype || o === Number.prototype
|| o === String.prototype) o = {};
if (o === Array.prototype) o = [];
if (o[key] === undefined || flags.bools[key] || typeof o[key] === 'boolean') {
o[key] = value;
}
else if (Array.isArray(o[key])) {
o[key].push(value);
}
else {
o[key] = [ o[key], value ];
}
}
function aliasIsBoolean(key) {
return aliases[key].some(function (x) {
return flags.bools[x];
});
}
for (var i = 0; i < args.length; i++) {
var arg = args[i];
if (/^--.+=/.test(arg)) {
// Using [\s\S] instead of . because js doesn't support the
// 'dotall' regex modifier. See:
// http://stackoverflow.com/a/1068308/13216
var m = arg.match(/^--([^=]+)=([\s\S]*)$/);
var key = m[1];
var value = m[2];
if (flags.bools[key]) {
value = value !== 'false';
}
setArg(key, value, arg);
}
else if (/^--no-.+/.test(arg)) {
var key = arg.match(/^--no-(.+)/)[1];
setArg(key, false, arg);
}
else if (/^--.+/.test(arg)) {
var key = arg.match(/^--(.+)/)[1];
var next = args[i + 1];
if (next !== undefined && !/^-/.test(next)
&& !flags.bools[key]
&& !flags.allBools
&& (aliases[key] ? !aliasIsBoolean(key) : true)) {
setArg(key, next, arg);
i++;
}
else if (/^(true|false)$/.test(next)) {
setArg(key, next === 'true', arg);
i++;
}
else {
setArg(key, flags.strings[key] ? '' : true, arg);
}
}
else if (/^-[^-]+/.test(arg)) {
var letters = arg.slice(1,-1).split('');
var broken = false;
for (var j = 0; j < letters.length; j++) {
var next = arg.slice(j+2);
if (next === '-') {
setArg(letters[j], next, arg)
continue;
}
if (/[A-Za-z]/.test(letters[j]) && /=/.test(next)) {
setArg(letters[j], next.split('=')[1], arg);
broken = true;
break;
}
if (/[A-Za-z]/.test(letters[j])
&& /-?\d+(\.\d*)?(e-?\d+)?$/.test(next)) {
setArg(letters[j], next, arg);
broken = true;
break;
}
if (letters[j+1] && letters[j+1].match(/\W/)) {
setArg(letters[j], arg.slice(j+2), arg);
broken = true;
break;
}
else {
setArg(letters[j], flags.strings[letters[j]] ? '' : true, arg);
}
}
var key = arg.slice(-1)[0];
if (!broken && key !== '-') {
if (args[i+1] && !/^(-|--)[^-]/.test(args[i+1])
&& !flags.bools[key]
&& (aliases[key] ? !aliasIsBoolean(key) : true)) {
setArg(key, args[i+1], arg);
i++;
}
else if (args[i+1] && /^(true|false)$/.test(args[i+1])) {
setArg(key, args[i+1] === 'true', arg);
i++;
}
else {
setArg(key, flags.strings[key] ? '' : true, arg);
}
}
}
else {
if (!flags.unknownFn || flags.unknownFn(arg) !== false) {
argv._.push(
flags.strings['_'] || !isNumber(arg) ? arg : Number(arg)
);
}
if (opts.stopEarly) {
argv._.push.apply(argv._, args.slice(i + 1));
break;
}
}
}
Object.keys(defaults).forEach(function (key) {
if (!hasKey(argv, key.split('.'))) {
setKey(argv, key.split('.'), defaults[key]);
(aliases[key] || []).forEach(function (x) {
setKey(argv, x.split('.'), defaults[key]);
});
}
});
if (opts['--']) {
argv['--'] = new Array();
notFlags.forEach(function(key) {
argv['--'].push(key);
});
}
else {
notFlags.forEach(function(key) {
argv._.push(key);
});
}
return argv;
};
function hasKey (obj, keys) {
var o = obj;
keys.slice(0,-1).forEach(function (key) {
o = (o[key] || {});
});
var key = keys[keys.length - 1];
return key in o;
}
function isNumber (x) {
if (typeof x === 'number') return true;
if (/^0x[0-9a-f]+$/i.test(x)) return true;
return /^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(x);
}

View File

@@ -0,0 +1,49 @@
{
"name": "minimist",
"version": "1.2.5",
"description": "parse argument options",
"main": "index.js",
"devDependencies": {
"covert": "^1.0.0",
"tap": "~0.4.0",
"tape": "^3.5.0"
},
"scripts": {
"test": "tap test/*.js",
"coverage": "covert test/*.js"
},
"testling": {
"files": "test/*.js",
"browsers": [
"ie/6..latest",
"ff/5",
"firefox/latest",
"chrome/10",
"chrome/latest",
"safari/5.1",
"safari/latest",
"opera/12"
]
},
"repository": {
"type": "git",
"url": "git://github.com/substack/minimist.git"
},
"homepage": "https://github.com/substack/minimist",
"keywords": [
"argv",
"getopt",
"parser",
"optimist"
],
"author": {
"name": "James Halliday",
"email": "mail@substack.net",
"url": "http://substack.net"
},
"license": "MIT"
,"_resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz"
,"_integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw=="
,"_from": "minimist@1.2.5"
}

View File

@@ -0,0 +1,95 @@
# minimist
parse argument options
This module is the guts of optimist's argument parser without all the
fanciful decoration.
# example
``` js
var argv = require('minimist')(process.argv.slice(2));
console.log(argv);
```
```
$ node example/parse.js -a beep -b boop
{ _: [], a: 'beep', b: 'boop' }
```
```
$ node example/parse.js -x 3 -y 4 -n5 -abc --beep=boop foo bar baz
{ _: [ 'foo', 'bar', 'baz' ],
x: 3,
y: 4,
n: 5,
a: true,
b: true,
c: true,
beep: 'boop' }
```
# security
Previous versions had a prototype pollution bug that could cause privilege
escalation in some circumstances when handling untrusted user input.
Please use version 1.2.3 or later: https://snyk.io/vuln/SNYK-JS-MINIMIST-559764
# methods
``` js
var parseArgs = require('minimist')
```
## var argv = parseArgs(args, opts={})
Return an argument object `argv` populated with the array arguments from `args`.
`argv._` contains all the arguments that didn't have an option associated with
them.
Numeric-looking arguments will be returned as numbers unless `opts.string` or
`opts.boolean` is set for that argument name.
Any arguments after `'--'` will not be parsed and will end up in `argv._`.
options can be:
* `opts.string` - a string or array of strings argument names to always treat as
strings
* `opts.boolean` - a boolean, string or array of strings to always treat as
booleans. if `true` will treat all double hyphenated arguments without equal signs
as boolean (e.g. affects `--foo`, not `-f` or `--foo=bar`)
* `opts.alias` - an object mapping string names to strings or arrays of string
argument names to use as aliases
* `opts.default` - an object mapping string argument names to default values
* `opts.stopEarly` - when true, populate `argv._` with everything after the
first non-option
* `opts['--']` - when true, populate `argv._` with everything before the `--`
and `argv['--']` with everything after the `--`. Here's an example:
```
> require('./')('one two three -- four five --six'.split(' '), { '--': true })
{ _: [ 'one', 'two', 'three' ],
'--': [ 'four', 'five', '--six' ] }
```
Note that with `opts['--']` set, parsing for arguments still stops after the
`--`.
* `opts.unknown` - a function which is invoked with a command line parameter not
defined in the `opts` configuration object. If the function returns `false`, the
unknown option is not added to `argv`.
# install
With [npm](https://npmjs.org) do:
```
npm install minimist
```
# license
MIT

View File

@@ -0,0 +1,32 @@
var parse = require('../');
var test = require('tape');
test('flag boolean true (default all --args to boolean)', function (t) {
var argv = parse(['moo', '--honk', 'cow'], {
boolean: true
});
t.deepEqual(argv, {
honk: true,
_: ['moo', 'cow']
});
t.deepEqual(typeof argv.honk, 'boolean');
t.end();
});
test('flag boolean true only affects double hyphen arguments without equals signs', function (t) {
var argv = parse(['moo', '--honk', 'cow', '-p', '55', '--tacos=good'], {
boolean: true
});
t.deepEqual(argv, {
honk: true,
tacos: 'good',
p: 55,
_: ['moo', 'cow']
});
t.deepEqual(typeof argv.honk, 'boolean');
t.end();
});

View File

@@ -0,0 +1,178 @@
var parse = require('../');
var test = require('tape');
test('flag boolean default false', function (t) {
var argv = parse(['moo'], {
boolean: ['t', 'verbose'],
default: { verbose: false, t: false }
});
t.deepEqual(argv, {
verbose: false,
t: false,
_: ['moo']
});
t.deepEqual(typeof argv.verbose, 'boolean');
t.deepEqual(typeof argv.t, 'boolean');
t.end();
});
test('boolean groups', function (t) {
var argv = parse([ '-x', '-z', 'one', 'two', 'three' ], {
boolean: ['x','y','z']
});
t.deepEqual(argv, {
x : true,
y : false,
z : true,
_ : [ 'one', 'two', 'three' ]
});
t.deepEqual(typeof argv.x, 'boolean');
t.deepEqual(typeof argv.y, 'boolean');
t.deepEqual(typeof argv.z, 'boolean');
t.end();
});
test('boolean and alias with chainable api', function (t) {
var aliased = [ '-h', 'derp' ];
var regular = [ '--herp', 'derp' ];
var opts = {
herp: { alias: 'h', boolean: true }
};
var aliasedArgv = parse(aliased, {
boolean: 'herp',
alias: { h: 'herp' }
});
var propertyArgv = parse(regular, {
boolean: 'herp',
alias: { h: 'herp' }
});
var expected = {
herp: true,
h: true,
'_': [ 'derp' ]
};
t.same(aliasedArgv, expected);
t.same(propertyArgv, expected);
t.end();
});
test('boolean and alias with options hash', function (t) {
var aliased = [ '-h', 'derp' ];
var regular = [ '--herp', 'derp' ];
var opts = {
alias: { 'h': 'herp' },
boolean: 'herp'
};
var aliasedArgv = parse(aliased, opts);
var propertyArgv = parse(regular, opts);
var expected = {
herp: true,
h: true,
'_': [ 'derp' ]
};
t.same(aliasedArgv, expected);
t.same(propertyArgv, expected);
t.end();
});
test('boolean and alias array with options hash', function (t) {
var aliased = [ '-h', 'derp' ];
var regular = [ '--herp', 'derp' ];
var alt = [ '--harp', 'derp' ];
var opts = {
alias: { 'h': ['herp', 'harp'] },
boolean: 'h'
};
var aliasedArgv = parse(aliased, opts);
var propertyArgv = parse(regular, opts);
var altPropertyArgv = parse(alt, opts);
var expected = {
harp: true,
herp: true,
h: true,
'_': [ 'derp' ]
};
t.same(aliasedArgv, expected);
t.same(propertyArgv, expected);
t.same(altPropertyArgv, expected);
t.end();
});
test('boolean and alias using explicit true', function (t) {
var aliased = [ '-h', 'true' ];
var regular = [ '--herp', 'true' ];
var opts = {
alias: { h: 'herp' },
boolean: 'h'
};
var aliasedArgv = parse(aliased, opts);
var propertyArgv = parse(regular, opts);
var expected = {
herp: true,
h: true,
'_': [ ]
};
t.same(aliasedArgv, expected);
t.same(propertyArgv, expected);
t.end();
});
// regression, see https://github.com/substack/node-optimist/issues/71
test('boolean and --x=true', function(t) {
var parsed = parse(['--boool', '--other=true'], {
boolean: 'boool'
});
t.same(parsed.boool, true);
t.same(parsed.other, 'true');
parsed = parse(['--boool', '--other=false'], {
boolean: 'boool'
});
t.same(parsed.boool, true);
t.same(parsed.other, 'false');
t.end();
});
test('boolean --boool=true', function (t) {
var parsed = parse(['--boool=true'], {
default: {
boool: false
},
boolean: ['boool']
});
t.same(parsed.boool, true);
t.end();
});
test('boolean --boool=false', function (t) {
var parsed = parse(['--boool=false'], {
default: {
boool: true
},
boolean: ['boool']
});
t.same(parsed.boool, false);
t.end();
});
test('boolean using something similar to true', function (t) {
var opts = { boolean: 'h' };
var result = parse(['-h', 'true.txt'], opts);
var expected = {
h: true,
'_': ['true.txt']
};
t.same(result, expected);
t.end();
});

View File

@@ -0,0 +1,31 @@
var parse = require('../');
var test = require('tape');
test('-', function (t) {
t.plan(5);
t.deepEqual(parse([ '-n', '-' ]), { n: '-', _: [] });
t.deepEqual(parse([ '-' ]), { _: [ '-' ] });
t.deepEqual(parse([ '-f-' ]), { f: '-', _: [] });
t.deepEqual(
parse([ '-b', '-' ], { boolean: 'b' }),
{ b: true, _: [ '-' ] }
);
t.deepEqual(
parse([ '-s', '-' ], { string: 's' }),
{ s: '-', _: [] }
);
});
test('-a -- b', function (t) {
t.plan(3);
t.deepEqual(parse([ '-a', '--', 'b' ]), { a: true, _: [ 'b' ] });
t.deepEqual(parse([ '--a', '--', 'b' ]), { a: true, _: [ 'b' ] });
t.deepEqual(parse([ '--a', '--', 'b' ]), { a: true, _: [ 'b' ] });
});
test('move arguments after the -- into their own `--` array', function(t) {
t.plan(1);
t.deepEqual(
parse([ '--name', 'John', 'before', '--', 'after' ], { '--': true }),
{ name: 'John', _: [ 'before' ], '--': [ 'after' ] });
});

View File

@@ -0,0 +1,35 @@
var test = require('tape');
var parse = require('../');
test('boolean default true', function (t) {
var argv = parse([], {
boolean: 'sometrue',
default: { sometrue: true }
});
t.equal(argv.sometrue, true);
t.end();
});
test('boolean default false', function (t) {
var argv = parse([], {
boolean: 'somefalse',
default: { somefalse: false }
});
t.equal(argv.somefalse, false);
t.end();
});
test('boolean default to null', function (t) {
var argv = parse([], {
boolean: 'maybe',
default: { maybe: null }
});
t.equal(argv.maybe, null);
var argv = parse(['--maybe'], {
boolean: 'maybe',
default: { maybe: null }
});
t.equal(argv.maybe, true);
t.end();
})

View File

@@ -0,0 +1,22 @@
var parse = require('../');
var test = require('tape');
test('dotted alias', function (t) {
var argv = parse(['--a.b', '22'], {default: {'a.b': 11}, alias: {'a.b': 'aa.bb'}});
t.equal(argv.a.b, 22);
t.equal(argv.aa.bb, 22);
t.end();
});
test('dotted default', function (t) {
var argv = parse('', {default: {'a.b': 11}, alias: {'a.b': 'aa.bb'}});
t.equal(argv.a.b, 11);
t.equal(argv.aa.bb, 11);
t.end();
});
test('dotted default with no alias', function (t) {
var argv = parse('', {default: {'a.b': 11}});
t.equal(argv.a.b, 11);
t.end();
});

View File

@@ -0,0 +1,16 @@
var parse = require('../');
var test = require('tape');
test('short -k=v' , function (t) {
t.plan(1);
var argv = parse([ '-b=123' ]);
t.deepEqual(argv, { b: 123, _: [] });
});
test('multi short -k=v' , function (t) {
t.plan(1);
var argv = parse([ '-a=whatever', '-b=robots' ]);
t.deepEqual(argv, { a: 'whatever', b: 'robots', _: [] });
});

View File

@@ -0,0 +1,31 @@
var test = require('tape');
var parse = require('../');
test('long opts', function (t) {
t.deepEqual(
parse([ '--bool' ]),
{ bool : true, _ : [] },
'long boolean'
);
t.deepEqual(
parse([ '--pow', 'xixxle' ]),
{ pow : 'xixxle', _ : [] },
'long capture sp'
);
t.deepEqual(
parse([ '--pow=xixxle' ]),
{ pow : 'xixxle', _ : [] },
'long capture eq'
);
t.deepEqual(
parse([ '--host', 'localhost', '--port', '555' ]),
{ host : 'localhost', port : 555, _ : [] },
'long captures sp'
);
t.deepEqual(
parse([ '--host=localhost', '--port=555' ]),
{ host : 'localhost', port : 555, _ : [] },
'long captures eq'
);
t.end();
});

View File

@@ -0,0 +1,36 @@
var parse = require('../');
var test = require('tape');
test('nums', function (t) {
var argv = parse([
'-x', '1234',
'-y', '5.67',
'-z', '1e7',
'-w', '10f',
'--hex', '0xdeadbeef',
'789'
]);
t.deepEqual(argv, {
x : 1234,
y : 5.67,
z : 1e7,
w : '10f',
hex : 0xdeadbeef,
_ : [ 789 ]
});
t.deepEqual(typeof argv.x, 'number');
t.deepEqual(typeof argv.y, 'number');
t.deepEqual(typeof argv.z, 'number');
t.deepEqual(typeof argv.w, 'string');
t.deepEqual(typeof argv.hex, 'number');
t.deepEqual(typeof argv._[0], 'number');
t.end();
});
test('already a number', function (t) {
var argv = parse([ '-x', 1234, 789 ]);
t.deepEqual(argv, { x : 1234, _ : [ 789 ] });
t.deepEqual(typeof argv.x, 'number');
t.deepEqual(typeof argv._[0], 'number');
t.end();
});

View File

@@ -0,0 +1,197 @@
var parse = require('../');
var test = require('tape');
test('parse args', function (t) {
t.deepEqual(
parse([ '--no-moo' ]),
{ moo : false, _ : [] },
'no'
);
t.deepEqual(
parse([ '-v', 'a', '-v', 'b', '-v', 'c' ]),
{ v : ['a','b','c'], _ : [] },
'multi'
);
t.end();
});
test('comprehensive', function (t) {
t.deepEqual(
parse([
'--name=meowmers', 'bare', '-cats', 'woo',
'-h', 'awesome', '--multi=quux',
'--key', 'value',
'-b', '--bool', '--no-meep', '--multi=baz',
'--', '--not-a-flag', 'eek'
]),
{
c : true,
a : true,
t : true,
s : 'woo',
h : 'awesome',
b : true,
bool : true,
key : 'value',
multi : [ 'quux', 'baz' ],
meep : false,
name : 'meowmers',
_ : [ 'bare', '--not-a-flag', 'eek' ]
}
);
t.end();
});
test('flag boolean', function (t) {
var argv = parse([ '-t', 'moo' ], { boolean: 't' });
t.deepEqual(argv, { t : true, _ : [ 'moo' ] });
t.deepEqual(typeof argv.t, 'boolean');
t.end();
});
test('flag boolean value', function (t) {
var argv = parse(['--verbose', 'false', 'moo', '-t', 'true'], {
boolean: [ 't', 'verbose' ],
default: { verbose: true }
});
t.deepEqual(argv, {
verbose: false,
t: true,
_: ['moo']
});
t.deepEqual(typeof argv.verbose, 'boolean');
t.deepEqual(typeof argv.t, 'boolean');
t.end();
});
test('newlines in params' , function (t) {
var args = parse([ '-s', "X\nX" ])
t.deepEqual(args, { _ : [], s : "X\nX" });
// reproduce in bash:
// VALUE="new
// line"
// node program.js --s="$VALUE"
args = parse([ "--s=X\nX" ])
t.deepEqual(args, { _ : [], s : "X\nX" });
t.end();
});
test('strings' , function (t) {
var s = parse([ '-s', '0001234' ], { string: 's' }).s;
t.equal(s, '0001234');
t.equal(typeof s, 'string');
var x = parse([ '-x', '56' ], { string: 'x' }).x;
t.equal(x, '56');
t.equal(typeof x, 'string');
t.end();
});
test('stringArgs', function (t) {
var s = parse([ ' ', ' ' ], { string: '_' })._;
t.same(s.length, 2);
t.same(typeof s[0], 'string');
t.same(s[0], ' ');
t.same(typeof s[1], 'string');
t.same(s[1], ' ');
t.end();
});
test('empty strings', function(t) {
var s = parse([ '-s' ], { string: 's' }).s;
t.equal(s, '');
t.equal(typeof s, 'string');
var str = parse([ '--str' ], { string: 'str' }).str;
t.equal(str, '');
t.equal(typeof str, 'string');
var letters = parse([ '-art' ], {
string: [ 'a', 't' ]
});
t.equal(letters.a, '');
t.equal(letters.r, true);
t.equal(letters.t, '');
t.end();
});
test('string and alias', function(t) {
var x = parse([ '--str', '000123' ], {
string: 's',
alias: { s: 'str' }
});
t.equal(x.str, '000123');
t.equal(typeof x.str, 'string');
t.equal(x.s, '000123');
t.equal(typeof x.s, 'string');
var y = parse([ '-s', '000123' ], {
string: 'str',
alias: { str: 's' }
});
t.equal(y.str, '000123');
t.equal(typeof y.str, 'string');
t.equal(y.s, '000123');
t.equal(typeof y.s, 'string');
t.end();
});
test('slashBreak', function (t) {
t.same(
parse([ '-I/foo/bar/baz' ]),
{ I : '/foo/bar/baz', _ : [] }
);
t.same(
parse([ '-xyz/foo/bar/baz' ]),
{ x : true, y : true, z : '/foo/bar/baz', _ : [] }
);
t.end();
});
test('alias', function (t) {
var argv = parse([ '-f', '11', '--zoom', '55' ], {
alias: { z: 'zoom' }
});
t.equal(argv.zoom, 55);
t.equal(argv.z, argv.zoom);
t.equal(argv.f, 11);
t.end();
});
test('multiAlias', function (t) {
var argv = parse([ '-f', '11', '--zoom', '55' ], {
alias: { z: [ 'zm', 'zoom' ] }
});
t.equal(argv.zoom, 55);
t.equal(argv.z, argv.zoom);
t.equal(argv.z, argv.zm);
t.equal(argv.f, 11);
t.end();
});
test('nested dotted objects', function (t) {
var argv = parse([
'--foo.bar', '3', '--foo.baz', '4',
'--foo.quux.quibble', '5', '--foo.quux.o_O',
'--beep.boop'
]);
t.same(argv.foo, {
bar : 3,
baz : 4,
quux : {
quibble : 5,
o_O : true
}
});
t.same(argv.beep, { boop : true });
t.end();
});

View File

@@ -0,0 +1,9 @@
var parse = require('../');
var test = require('tape');
test('parse with modifier functions' , function (t) {
t.plan(1);
var argv = parse([ '-b', '123' ], { boolean: 'b' });
t.deepEqual(argv, { b: true, _: [123] });
});

View File

@@ -0,0 +1,44 @@
var parse = require('../');
var test = require('tape');
test('proto pollution', function (t) {
var argv = parse(['--__proto__.x','123']);
t.equal({}.x, undefined);
t.equal(argv.__proto__.x, undefined);
t.equal(argv.x, undefined);
t.end();
});
test('proto pollution (array)', function (t) {
var argv = parse(['--x','4','--x','5','--x.__proto__.z','789']);
t.equal({}.z, undefined);
t.deepEqual(argv.x, [4,5]);
t.equal(argv.x.z, undefined);
t.equal(argv.x.__proto__.z, undefined);
t.end();
});
test('proto pollution (number)', function (t) {
var argv = parse(['--x','5','--x.__proto__.z','100']);
t.equal({}.z, undefined);
t.equal((4).z, undefined);
t.equal(argv.x, 5);
t.equal(argv.x.z, undefined);
t.end();
});
test('proto pollution (string)', function (t) {
var argv = parse(['--x','abc','--x.__proto__.z','def']);
t.equal({}.z, undefined);
t.equal('...'.z, undefined);
t.equal(argv.x, 'abc');
t.equal(argv.x.z, undefined);
t.end();
});
test('proto pollution (constructor)', function (t) {
var argv = parse(['--constructor.prototype.y','123']);
t.equal({}.y, undefined);
t.equal(argv.y, undefined);
t.end();
});

View File

@@ -0,0 +1,67 @@
var parse = require('../');
var test = require('tape');
test('numeric short args', function (t) {
t.plan(2);
t.deepEqual(parse([ '-n123' ]), { n: 123, _: [] });
t.deepEqual(
parse([ '-123', '456' ]),
{ 1: true, 2: true, 3: 456, _: [] }
);
});
test('short', function (t) {
t.deepEqual(
parse([ '-b' ]),
{ b : true, _ : [] },
'short boolean'
);
t.deepEqual(
parse([ 'foo', 'bar', 'baz' ]),
{ _ : [ 'foo', 'bar', 'baz' ] },
'bare'
);
t.deepEqual(
parse([ '-cats' ]),
{ c : true, a : true, t : true, s : true, _ : [] },
'group'
);
t.deepEqual(
parse([ '-cats', 'meow' ]),
{ c : true, a : true, t : true, s : 'meow', _ : [] },
'short group next'
);
t.deepEqual(
parse([ '-h', 'localhost' ]),
{ h : 'localhost', _ : [] },
'short capture'
);
t.deepEqual(
parse([ '-h', 'localhost', '-p', '555' ]),
{ h : 'localhost', p : 555, _ : [] },
'short captures'
);
t.end();
});
test('mixed short bool and capture', function (t) {
t.same(
parse([ '-h', 'localhost', '-fp', '555', 'script.js' ]),
{
f : true, p : 555, h : 'localhost',
_ : [ 'script.js' ]
}
);
t.end();
});
test('short and long', function (t) {
t.deepEqual(
parse([ '-h', 'localhost', '-fp', '555', 'script.js' ]),
{
f : true, p : 555, h : 'localhost',
_ : [ 'script.js' ]
}
);
t.end();
});

View File

@@ -0,0 +1,15 @@
var parse = require('../');
var test = require('tape');
test('stops parsing on the first non-option when stopEarly is set', function (t) {
var argv = parse(['--aaa', 'bbb', 'ccc', '--ddd'], {
stopEarly: true
});
t.deepEqual(argv, {
aaa: 'bbb',
_: ['ccc', '--ddd']
});
t.end();
});

View File

@@ -0,0 +1,102 @@
var parse = require('../');
var test = require('tape');
test('boolean and alias is not unknown', function (t) {
var unknown = [];
function unknownFn(arg) {
unknown.push(arg);
return false;
}
var aliased = [ '-h', 'true', '--derp', 'true' ];
var regular = [ '--herp', 'true', '-d', 'true' ];
var opts = {
alias: { h: 'herp' },
boolean: 'h',
unknown: unknownFn
};
var aliasedArgv = parse(aliased, opts);
var propertyArgv = parse(regular, opts);
t.same(unknown, ['--derp', '-d']);
t.end();
});
test('flag boolean true any double hyphen argument is not unknown', function (t) {
var unknown = [];
function unknownFn(arg) {
unknown.push(arg);
return false;
}
var argv = parse(['--honk', '--tacos=good', 'cow', '-p', '55'], {
boolean: true,
unknown: unknownFn
});
t.same(unknown, ['--tacos=good', 'cow', '-p']);
t.same(argv, {
honk: true,
_: []
});
t.end();
});
test('string and alias is not unknown', function (t) {
var unknown = [];
function unknownFn(arg) {
unknown.push(arg);
return false;
}
var aliased = [ '-h', 'hello', '--derp', 'goodbye' ];
var regular = [ '--herp', 'hello', '-d', 'moon' ];
var opts = {
alias: { h: 'herp' },
string: 'h',
unknown: unknownFn
};
var aliasedArgv = parse(aliased, opts);
var propertyArgv = parse(regular, opts);
t.same(unknown, ['--derp', '-d']);
t.end();
});
test('default and alias is not unknown', function (t) {
var unknown = [];
function unknownFn(arg) {
unknown.push(arg);
return false;
}
var aliased = [ '-h', 'hello' ];
var regular = [ '--herp', 'hello' ];
var opts = {
default: { 'h': 'bar' },
alias: { 'h': 'herp' },
unknown: unknownFn
};
var aliasedArgv = parse(aliased, opts);
var propertyArgv = parse(regular, opts);
t.same(unknown, []);
t.end();
unknownFn(); // exercise fn for 100% coverage
});
test('value following -- is not unknown', function (t) {
var unknown = [];
function unknownFn(arg) {
unknown.push(arg);
return false;
}
var aliased = [ '--bad', '--', 'good', 'arg' ];
var opts = {
'--': true,
unknown: unknownFn
};
var argv = parse(aliased, opts);
t.same(unknown, ['--bad']);
t.same(argv, {
'--': ['good', 'arg'],
'_': []
})
t.end();
});

View File

@@ -0,0 +1,8 @@
var parse = require('../');
var test = require('tape');
test('whitespace should be whitespace' , function (t) {
t.plan(1);
var x = parse([ '-x', '\t' ]).x;
t.equal(x, '\t');
});

View File

@@ -0,0 +1,69 @@
{
"name": "lorem-ipsum",
"displayName": "Lorem ipsum",
"description": "Generates and inserts lorem ipsum text",
"version": "1.3.1",
"license": "MIT",
"bugs": {
"url": "https://github.com/Tyriar/vscode-lorem-ipsum/issues"
},
"scripts": {
"test": "mocha",
"compile-web": "webpack",
"watch-web": "webpack --watch",
"package-web": "webpack --mode production --devtool hidden-source-map"
},
"homepage": "https://github.com/Tyriar/vscode-lorem-ipsum",
"repository": {
"type": "git",
"url": "https://github.com/Tyriar/vscode-lorem-ipsum"
},
"publisher": "Tyriar",
"engines": {
"vscode": "0.10.x"
},
"categories": [
"Other"
],
"activationEvents": [
"onCommand:lorem-ipsum.line",
"onCommand:lorem-ipsum.paragraph",
"onCommand:lorem-ipsum.multipleParagraphs"
],
"main": "./extension",
"browser": "./dist/web/extension.js",
"contributes": {
"commands": [
{
"command": "lorem-ipsum.line",
"title": "Lorem Ipsum: Insert a line"
},
{
"command": "lorem-ipsum.paragraph",
"title": "Lorem Ipsum: Insert a paragraph"
},
{
"command": "lorem-ipsum.multipleParagraphs",
"title": "Lorem Ipsum: Insert multiple paragraphs"
}
]
},
"devDependencies": {
"@types/webpack-env": "^1.16.3",
"mocha": "~2.3.3",
"vscode": "0.10.x",
"webpack": "^5.65.0",
"webpack-cli": "^4.9.1"
},
"dependencies": {
"lorem-ipsum": "^1.0.3"
},
"icon": "images/icon.png",
"__metadata": {
"id": "489abeb0-400c-4a08-bde4-cf5d9b863a32",
"publisherId": "738ff3bb-8e77-45d5-bd26-7c9ad62959b9",
"publisherDisplayName": "Daniel Imms",
"isPreReleaseVersion": false,
"installedTimestamp": 1641229810404
}
}