@stdlib/string-lowercase-cli 0.1.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/NOTICE +1 -1
- package/README.md +6 -3
- package/package.json +9 -9
- package/.github/workflows/publish_cli.yml +0 -170
- package/CONTRIBUTORS +0 -39
- package/test/fixtures/stdin_error.js.txt +0 -33
- package/test/test.cli.js +0 -219
package/NOTICE
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Copyright (c) 2016-
|
|
1
|
+
Copyright (c) 2016-2024 The Stdlib Authors.
|
package/README.md
CHANGED
|
@@ -148,7 +148,7 @@ See [LICENSE][stdlib-license].
|
|
|
148
148
|
|
|
149
149
|
## Copyright
|
|
150
150
|
|
|
151
|
-
Copyright © 2016-
|
|
151
|
+
Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors].
|
|
152
152
|
|
|
153
153
|
</section>
|
|
154
154
|
|
|
@@ -161,8 +161,8 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors].
|
|
|
161
161
|
[npm-image]: http://img.shields.io/npm/v/@stdlib/string-lowercase-cli.svg
|
|
162
162
|
[npm-url]: https://npmjs.org/package/@stdlib/string-lowercase-cli
|
|
163
163
|
|
|
164
|
-
[test-image]: https://github.com/stdlib-js/string-lowercase/actions/workflows/test.yml/badge.svg?branch=v0.
|
|
165
|
-
[test-url]: https://github.com/stdlib-js/string-lowercase/actions/workflows/test.yml?query=branch:v0.
|
|
164
|
+
[test-image]: https://github.com/stdlib-js/string-lowercase/actions/workflows/test.yml/badge.svg?branch=v0.2.0
|
|
165
|
+
[test-url]: https://github.com/stdlib-js/string-lowercase/actions/workflows/test.yml?query=branch:v0.2.0
|
|
166
166
|
|
|
167
167
|
[coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/string-lowercase/main.svg
|
|
168
168
|
[coverage-url]: https://codecov.io/github/stdlib-js/string-lowercase?branch=main
|
|
@@ -189,8 +189,11 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors].
|
|
|
189
189
|
[es-module]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules
|
|
190
190
|
|
|
191
191
|
[deno-url]: https://github.com/stdlib-js/string-lowercase/tree/deno
|
|
192
|
+
[deno-readme]: https://github.com/stdlib-js/string-lowercase/blob/deno/README.md
|
|
192
193
|
[umd-url]: https://github.com/stdlib-js/string-lowercase/tree/umd
|
|
194
|
+
[umd-readme]: https://github.com/stdlib-js/string-lowercase/blob/umd/README.md
|
|
193
195
|
[esm-url]: https://github.com/stdlib-js/string-lowercase/tree/esm
|
|
196
|
+
[esm-readme]: https://github.com/stdlib-js/string-lowercase/blob/esm/README.md
|
|
194
197
|
[branches-url]: https://github.com/stdlib-js/string-lowercase/blob/main/branches.md
|
|
195
198
|
|
|
196
199
|
[stdlib-license]: https://raw.githubusercontent.com/stdlib-js/string-lowercase/main/LICENSE
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stdlib/string-lowercase-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Convert a string to lowercase.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": {
|
|
@@ -26,16 +26,16 @@
|
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@stdlib/cli-ctor": "^0.1.1",
|
|
29
|
-
"@stdlib/fs-read-file": "^0.
|
|
30
|
-
"@stdlib/process-read-stdin": "^0.
|
|
31
|
-
"@stdlib/streams-node-stdin": "^0.
|
|
32
|
-
"@stdlib/string-lowercase": "0.
|
|
29
|
+
"@stdlib/fs-read-file": "^0.2.0",
|
|
30
|
+
"@stdlib/process-read-stdin": "^0.2.0",
|
|
31
|
+
"@stdlib/streams-node-stdin": "^0.2.0",
|
|
32
|
+
"@stdlib/string-lowercase": "0.2.0"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
|
-
"@stdlib/assert-is-browser": "^0.1.
|
|
36
|
-
"@stdlib/assert-is-windows": "^0.1.
|
|
37
|
-
"@stdlib/process-exec-path": "^0.1.
|
|
38
|
-
"@stdlib/string-replace": "^0.1.
|
|
35
|
+
"@stdlib/assert-is-browser": "^0.1.1",
|
|
36
|
+
"@stdlib/assert-is-windows": "^0.1.1",
|
|
37
|
+
"@stdlib/process-exec-path": "^0.1.1",
|
|
38
|
+
"@stdlib/string-replace": "^0.1.1",
|
|
39
39
|
"tape": "git+https://github.com/kgryte/tape.git#fix/globby",
|
|
40
40
|
"proxyquire": "^2.0.0",
|
|
41
41
|
"istanbul": "^0.4.1",
|
|
@@ -1,170 +0,0 @@
|
|
|
1
|
-
#/
|
|
2
|
-
# @license Apache-2.0
|
|
3
|
-
#
|
|
4
|
-
# Copyright (c) 2023 The Stdlib Authors.
|
|
5
|
-
#
|
|
6
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
-
# you may not use this file except in compliance with the License.
|
|
8
|
-
# You may obtain a copy of the License at
|
|
9
|
-
#
|
|
10
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
-
#
|
|
12
|
-
# Unless required by applicable law or agreed to in writing, software
|
|
13
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
-
# See the License for the specific language governing permissions and
|
|
16
|
-
# limitations under the License.
|
|
17
|
-
#/
|
|
18
|
-
|
|
19
|
-
# Workflow name:
|
|
20
|
-
name: publish_cli
|
|
21
|
-
|
|
22
|
-
# Workflow triggers:
|
|
23
|
-
on:
|
|
24
|
-
# Allow the workflow to be manually run:
|
|
25
|
-
workflow_dispatch:
|
|
26
|
-
# Workflow inputs:
|
|
27
|
-
inputs:
|
|
28
|
-
version:
|
|
29
|
-
description: 'Version Increment'
|
|
30
|
-
type: choice
|
|
31
|
-
default: 'none'
|
|
32
|
-
options:
|
|
33
|
-
- 'none'
|
|
34
|
-
- 'major'
|
|
35
|
-
- 'minor'
|
|
36
|
-
- 'patch'
|
|
37
|
-
- 'premajor'
|
|
38
|
-
- 'preminor'
|
|
39
|
-
- 'prepatch'
|
|
40
|
-
- 'prerelease'
|
|
41
|
-
|
|
42
|
-
# Workflow jobs:
|
|
43
|
-
jobs:
|
|
44
|
-
|
|
45
|
-
# Define job to publish package to npm:
|
|
46
|
-
publish:
|
|
47
|
-
|
|
48
|
-
# Define display name:
|
|
49
|
-
name: 'Publish CLI package to npm'
|
|
50
|
-
|
|
51
|
-
# Define the type of virtual host machine on which to run the job:
|
|
52
|
-
runs-on: ubuntu-latest
|
|
53
|
-
|
|
54
|
-
# Define environment variables:
|
|
55
|
-
env:
|
|
56
|
-
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
|
|
57
|
-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
58
|
-
|
|
59
|
-
# Define the sequence of job steps...
|
|
60
|
-
steps:
|
|
61
|
-
|
|
62
|
-
# Checkout cli branch:
|
|
63
|
-
- name: 'Checkout cli branch'
|
|
64
|
-
# Pin action to full length commit SHA corresponding to v4.1.0
|
|
65
|
-
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608
|
|
66
|
-
with:
|
|
67
|
-
ref: cli
|
|
68
|
-
|
|
69
|
-
# Install Node.js:
|
|
70
|
-
- name: 'Install Node.js'
|
|
71
|
-
# Pin action to full length commit SHA corresponding to v3.8.1
|
|
72
|
-
uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d
|
|
73
|
-
with:
|
|
74
|
-
node-version: 16
|
|
75
|
-
timeout-minutes: 5
|
|
76
|
-
|
|
77
|
-
# Configure git:
|
|
78
|
-
- name: 'Configure git'
|
|
79
|
-
run: |
|
|
80
|
-
git config --local user.email "noreply@stdlib.io"
|
|
81
|
-
git config --local user.name "stdlib-bot"
|
|
82
|
-
|
|
83
|
-
# Increment package version (if requested):
|
|
84
|
-
- name: 'Increment package version (if requested)'
|
|
85
|
-
if: ${{ github.event.inputs.version != 'none' }}
|
|
86
|
-
run: |
|
|
87
|
-
# Save NPM_TOKEN to user's .npmrc:
|
|
88
|
-
echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc
|
|
89
|
-
|
|
90
|
-
# Increment package version:
|
|
91
|
-
npm version ${{ github.event.inputs.version }} --no-git-tag-version
|
|
92
|
-
|
|
93
|
-
# Define variable for new version:
|
|
94
|
-
NEW_VERSION=$(node -p "require('./package.json').version")
|
|
95
|
-
|
|
96
|
-
# Replace branch in README.md link definitions for badges with the new version:
|
|
97
|
-
find . -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/branch([=:])[^ ]+/branch\1v${NEW_VERSION}/g"
|
|
98
|
-
|
|
99
|
-
# Create a new commit and tag:
|
|
100
|
-
git add package.json README.md
|
|
101
|
-
git commit -m "Release v${NEW_VERSION}"
|
|
102
|
-
git tag -a "v${NEW_VERSION}-cli" -m "Release v${NEW_VERSION}"
|
|
103
|
-
|
|
104
|
-
# Push changes to GitHub:
|
|
105
|
-
SLUG=${{ github.repository }}
|
|
106
|
-
git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" --follow-tags
|
|
107
|
-
|
|
108
|
-
# Replace GitHub MathJax equations with SVGs:
|
|
109
|
-
- name: 'Replace GitHub MathJax equations with SVGs'
|
|
110
|
-
run: |
|
|
111
|
-
find . -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe 's/```math\n([\s\S]+?)\n```\n\n//g'
|
|
112
|
-
find . -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe 's/<!-- <div class="equation"(.*)(<\/div>\s*-->)/<div class="equation"$1<\/div>/sg'
|
|
113
|
-
|
|
114
|
-
# Replace GitHub links to individual packages with npm links:
|
|
115
|
-
- name: 'Replace all GitHub links to individual packages with npm links'
|
|
116
|
-
run: |
|
|
117
|
-
find . -type f -name '*.md' -print0 | xargs -0 sed -Ei '/tree\/main/b; s/@stdlib\/([^:]*)\]: https:\/\/github.com\/stdlib-js/@stdlib\/\1\]: https:\/\/www.npmjs.com\/package\/@stdlib/g'
|
|
118
|
-
SLUG=${{ github.repository }}
|
|
119
|
-
ESCAPED_SLUG=${SLUG//\//\\\/}
|
|
120
|
-
REPO=${SLUG#*/}
|
|
121
|
-
find . -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/https:\/\/github.com\/${ESCAPED_SLUG}\/tree\/main/https:\/\/www.npmjs.com\/package\/@stdlib\/${REPO}/g"
|
|
122
|
-
|
|
123
|
-
# Publish package to npm:
|
|
124
|
-
- name: 'Publish package to npm'
|
|
125
|
-
# Pin action to full length commit SHA corresponding to v2.2.2
|
|
126
|
-
uses: JS-DevTools/npm-publish@fe72237be0920f7a0cafd6a966c9b929c9466e9b
|
|
127
|
-
with:
|
|
128
|
-
token: ${{ secrets.NPM_TOKEN }}
|
|
129
|
-
access: public
|
|
130
|
-
|
|
131
|
-
# Discard any uncommitted changes:
|
|
132
|
-
- name: 'Discard any uncommitted changes'
|
|
133
|
-
run: |
|
|
134
|
-
git reset --hard
|
|
135
|
-
|
|
136
|
-
# Send status to Slack channel if job fails:
|
|
137
|
-
- name: 'Send status to Slack channel in case of failure'
|
|
138
|
-
# Pin action to full length commit SHA corresponding to v2.0.0
|
|
139
|
-
uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f
|
|
140
|
-
with:
|
|
141
|
-
status: ${{ job.status }}
|
|
142
|
-
steps: ${{ toJson(steps) }}
|
|
143
|
-
channel: '#npm-ci'
|
|
144
|
-
if: failure()
|
|
145
|
-
|
|
146
|
-
# Define job to cancel any running or queued workflow runs...
|
|
147
|
-
cancel:
|
|
148
|
-
|
|
149
|
-
# Define the type of virtual host machine on which to run the job:
|
|
150
|
-
runs-on: ubuntu-latest
|
|
151
|
-
|
|
152
|
-
# Time out the job after 3 minutes:
|
|
153
|
-
timeout-minutes: 3
|
|
154
|
-
|
|
155
|
-
# Define the sequence of job steps...
|
|
156
|
-
steps:
|
|
157
|
-
|
|
158
|
-
# Cancel any running or queued workflow runs:
|
|
159
|
-
- name: 'Cancel running or queued workflow runs'
|
|
160
|
-
# Pin action to full length commit SHA corresponding to v0.11.0
|
|
161
|
-
uses: styfle/cancel-workflow-action@b173b6ec0100793626c2d9e6b90435061f4fc3e5
|
|
162
|
-
with:
|
|
163
|
-
workflow_id: >-
|
|
164
|
-
benchmark.yml,
|
|
165
|
-
examples.yml,
|
|
166
|
-
test.yml,
|
|
167
|
-
test_coverage.yml,
|
|
168
|
-
test_install.yml,
|
|
169
|
-
publish.yml
|
|
170
|
-
access_token: ${{ github.token }}
|
package/CONTRIBUTORS
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
# This file is generated by tools/scripts/update_contributors.
|
|
2
|
-
#
|
|
3
|
-
# Contributors listed in alphabetical order.
|
|
4
|
-
|
|
5
|
-
Ali Salesi <ali_sal1381@yahoo.com>
|
|
6
|
-
Amit Jimiwal <amitjimiwal45@gmail.com>
|
|
7
|
-
Athan Reines <kgryte@gmail.com>
|
|
8
|
-
Brendan Graetz <bguiz@users.noreply.github.com>
|
|
9
|
-
Bruno Fenzl <brunofenzl@gmail.com>
|
|
10
|
-
Christopher Dambamuromo <chridam@gmail.com>
|
|
11
|
-
Dan Rose <danoftheroses@gmail.com>
|
|
12
|
-
Dominik Moritz <domoritz@gmail.com>
|
|
13
|
-
Dorrin Sotoudeh <dorrinsotoudeh123@gmail.com>
|
|
14
|
-
Frank Kovacs <fran70kk@gmail.com>
|
|
15
|
-
Harshita Kalani <harshitakalani02@gmail.com>
|
|
16
|
-
James Gelok <jdgelok@gmail.com>
|
|
17
|
-
Jithin KS <jithinks112@gmail.com>
|
|
18
|
-
Joey Reed <joeyrreed@gmail.com>
|
|
19
|
-
Jordan Gallivan <115050475+Jordan-Gallivan@users.noreply.github.com>
|
|
20
|
-
Joris Labie <joris.labie1@gmail.com>
|
|
21
|
-
Justin Dennison <justin1dennison@gmail.com>
|
|
22
|
-
Marcus Fantham <mfantham@users.noreply.github.com>
|
|
23
|
-
Matt Cochrane <matthew.cochrane.eng@gmail.com>
|
|
24
|
-
Milan Raj <rajsite@users.noreply.github.com>
|
|
25
|
-
Momtchil Momtchev <momtchil@momtchev.com>
|
|
26
|
-
Naresh Jagadeesan <naresh.naresh000@gmail.com>
|
|
27
|
-
Nithin Katta <88046362+nithinkatta@users.noreply.github.com>
|
|
28
|
-
Ognjen Jevremović <ognjenjevremovic@users.noreply.github.com>
|
|
29
|
-
Philipp Burckhardt <pburckhardt@outlook.com>
|
|
30
|
-
Pranav Goswami <goswami.4@iitj.ac.in>
|
|
31
|
-
Ricky Reusser <rsreusser@gmail.com>
|
|
32
|
-
Roman Stetsyk <25715951+romanstetsyk@users.noreply.github.com>
|
|
33
|
-
Ryan Seal <splrk@users.noreply.github.com>
|
|
34
|
-
Seyyed Parsa Neshaei <spneshaei@users.noreply.github.com>
|
|
35
|
-
Shraddheya Shendre <shendreshraddheya@gmail.com>
|
|
36
|
-
Stephannie Jiménez Gacha <steff456@hotmail.com>
|
|
37
|
-
Yernar Yergaziyev <yernar.yergaziyev@erg.kz>
|
|
38
|
-
orimiles5 <97595296+orimiles5@users.noreply.github.com>
|
|
39
|
-
rei2hu <reimu@reimu.ws>
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Apache-2.0
|
|
3
|
-
*
|
|
4
|
-
* Copyright (c) 2018 The Stdlib Authors.
|
|
5
|
-
*
|
|
6
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
-
* you may not use this file except in compliance with the License.
|
|
8
|
-
* You may obtain a copy of the License at
|
|
9
|
-
*
|
|
10
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
-
*
|
|
12
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
-
* See the License for the specific language governing permissions and
|
|
16
|
-
* limitations under the License.
|
|
17
|
-
*/
|
|
18
|
-
|
|
19
|
-
var proc = require( 'process' );
|
|
20
|
-
var resolve = require( 'path' ).resolve;
|
|
21
|
-
var proxyquire = require( 'proxyquire' );
|
|
22
|
-
|
|
23
|
-
var fpath = resolve( __dirname, '..', 'bin', 'cli' );
|
|
24
|
-
|
|
25
|
-
proc.stdin.isTTY = false;
|
|
26
|
-
|
|
27
|
-
proxyquire( fpath, {
|
|
28
|
-
'@stdlib/process-read-stdin': stdin
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
function stdin( clbk ) {
|
|
32
|
-
clbk( new Error( 'beep' ) );
|
|
33
|
-
}
|
package/test/test.cli.js
DELETED
|
@@ -1,219 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Apache-2.0
|
|
3
|
-
*
|
|
4
|
-
* Copyright (c) 2018 The Stdlib Authors.
|
|
5
|
-
*
|
|
6
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
-
* you may not use this file except in compliance with the License.
|
|
8
|
-
* You may obtain a copy of the License at
|
|
9
|
-
*
|
|
10
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
-
*
|
|
12
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
-
* See the License for the specific language governing permissions and
|
|
16
|
-
* limitations under the License.
|
|
17
|
-
*/
|
|
18
|
-
|
|
19
|
-
'use strict';
|
|
20
|
-
|
|
21
|
-
// MODULES //
|
|
22
|
-
|
|
23
|
-
var resolve = require( 'path' ).resolve;
|
|
24
|
-
var exec = require( 'child_process' ).exec;
|
|
25
|
-
var tape = require( 'tape' );
|
|
26
|
-
var IS_BROWSER = require( '@stdlib/assert-is-browser' );
|
|
27
|
-
var IS_WINDOWS = require( '@stdlib/assert-is-windows' );
|
|
28
|
-
var replace = require( '@stdlib/string-replace' );
|
|
29
|
-
var readFileSync = require( '@stdlib/fs-read-file' ).sync;
|
|
30
|
-
var EXEC_PATH = require( '@stdlib/process-exec-path' );
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
// VARIABLES //
|
|
34
|
-
|
|
35
|
-
var fpath = resolve( __dirname, '..', 'bin', 'cli' );
|
|
36
|
-
var opts = {
|
|
37
|
-
'skip': IS_BROWSER || IS_WINDOWS
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
// FIXTURES //
|
|
42
|
-
|
|
43
|
-
var PKG_VERSION = require( './../package.json' ).version;
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
// TESTS //
|
|
47
|
-
|
|
48
|
-
tape( 'command-line interface', function test( t ) {
|
|
49
|
-
t.ok( true, __filename );
|
|
50
|
-
t.end();
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
tape( 'when invoked with a `--help` flag, the command-line interface prints the help text to `stderr`', opts, function test( t ) {
|
|
54
|
-
var expected;
|
|
55
|
-
var cmd;
|
|
56
|
-
|
|
57
|
-
expected = readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), {
|
|
58
|
-
'encoding': 'utf8'
|
|
59
|
-
});
|
|
60
|
-
cmd = [
|
|
61
|
-
EXEC_PATH,
|
|
62
|
-
fpath,
|
|
63
|
-
'--help'
|
|
64
|
-
];
|
|
65
|
-
|
|
66
|
-
exec( cmd.join( ' ' ), done );
|
|
67
|
-
|
|
68
|
-
function done( error, stdout, stderr ) {
|
|
69
|
-
if ( error ) {
|
|
70
|
-
t.fail( error.message );
|
|
71
|
-
} else {
|
|
72
|
-
t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' );
|
|
73
|
-
t.strictEqual( stderr.toString(), expected+'\n', 'expected value' );
|
|
74
|
-
}
|
|
75
|
-
t.end();
|
|
76
|
-
}
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
tape( 'when invoked with a `-h` flag, the command-line interface prints the help text to `stderr`', opts, function test( t ) {
|
|
80
|
-
var expected;
|
|
81
|
-
var cmd;
|
|
82
|
-
|
|
83
|
-
expected = readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), {
|
|
84
|
-
'encoding': 'utf8'
|
|
85
|
-
});
|
|
86
|
-
cmd = [
|
|
87
|
-
EXEC_PATH,
|
|
88
|
-
fpath,
|
|
89
|
-
'-h'
|
|
90
|
-
];
|
|
91
|
-
|
|
92
|
-
exec( cmd.join( ' ' ), done );
|
|
93
|
-
|
|
94
|
-
function done( error, stdout, stderr ) {
|
|
95
|
-
if ( error ) {
|
|
96
|
-
t.fail( error.message );
|
|
97
|
-
} else {
|
|
98
|
-
t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' );
|
|
99
|
-
t.strictEqual( stderr.toString(), expected+'\n', 'expected value' );
|
|
100
|
-
}
|
|
101
|
-
t.end();
|
|
102
|
-
}
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
tape( 'when invoked with a `--version` flag, the command-line interface prints the version to `stderr`', opts, function test( t ) {
|
|
106
|
-
var cmd = [
|
|
107
|
-
EXEC_PATH,
|
|
108
|
-
fpath,
|
|
109
|
-
'--version'
|
|
110
|
-
];
|
|
111
|
-
|
|
112
|
-
exec( cmd.join( ' ' ), done );
|
|
113
|
-
|
|
114
|
-
function done( error, stdout, stderr ) {
|
|
115
|
-
if ( error ) {
|
|
116
|
-
t.fail( error.message );
|
|
117
|
-
} else {
|
|
118
|
-
t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' );
|
|
119
|
-
t.strictEqual( stderr.toString(), PKG_VERSION+'\n', 'expected value' );
|
|
120
|
-
}
|
|
121
|
-
t.end();
|
|
122
|
-
}
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
tape( 'when invoked with a `-V` flag, the command-line interface prints the version to `stderr`', opts, function test( t ) {
|
|
126
|
-
var cmd = [
|
|
127
|
-
EXEC_PATH,
|
|
128
|
-
fpath,
|
|
129
|
-
'-V'
|
|
130
|
-
];
|
|
131
|
-
|
|
132
|
-
exec( cmd.join( ' ' ), done );
|
|
133
|
-
|
|
134
|
-
function done( error, stdout, stderr ) {
|
|
135
|
-
if ( error ) {
|
|
136
|
-
t.fail( error.message );
|
|
137
|
-
} else {
|
|
138
|
-
t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' );
|
|
139
|
-
t.strictEqual( stderr.toString(), PKG_VERSION+'\n', 'expected value' );
|
|
140
|
-
}
|
|
141
|
-
t.end();
|
|
142
|
-
}
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
tape( 'the command-line interface converts a string argument to lowercase', opts, function test( t ) {
|
|
146
|
-
var cmd = [
|
|
147
|
-
EXEC_PATH,
|
|
148
|
-
'-e',
|
|
149
|
-
'"process.stdin.isTTY = true; process.argv[ 2 ] = \'bEEp\'; require( \''+fpath+'\' );"'
|
|
150
|
-
];
|
|
151
|
-
|
|
152
|
-
exec( cmd.join( ' ' ), done );
|
|
153
|
-
|
|
154
|
-
function done( error, stdout, stderr ) {
|
|
155
|
-
if ( error ) {
|
|
156
|
-
t.fail( error.message );
|
|
157
|
-
} else {
|
|
158
|
-
t.strictEqual( stdout.toString(), 'beep\n', 'expected value' );
|
|
159
|
-
t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' );
|
|
160
|
-
}
|
|
161
|
-
t.end();
|
|
162
|
-
}
|
|
163
|
-
});
|
|
164
|
-
|
|
165
|
-
tape( 'the command-line interface supports use as a standard stream', opts, function test( t ) {
|
|
166
|
-
var cmd = [
|
|
167
|
-
'printf bEEp',
|
|
168
|
-
'|',
|
|
169
|
-
EXEC_PATH,
|
|
170
|
-
fpath
|
|
171
|
-
];
|
|
172
|
-
|
|
173
|
-
exec( cmd.join( ' ' ), done );
|
|
174
|
-
|
|
175
|
-
function done( error, stdout, stderr ) {
|
|
176
|
-
if ( error ) {
|
|
177
|
-
t.fail( error.message );
|
|
178
|
-
} else {
|
|
179
|
-
t.strictEqual( stdout.toString(), 'beep\n', 'expected value' );
|
|
180
|
-
t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' );
|
|
181
|
-
}
|
|
182
|
-
t.end();
|
|
183
|
-
}
|
|
184
|
-
});
|
|
185
|
-
|
|
186
|
-
tape( 'when used as a standard stream, if an error is encountered when reading from `stdin`, the command-line interface prints an error and sets a non-zero exit code', opts, function test( t ) {
|
|
187
|
-
var script;
|
|
188
|
-
var opts;
|
|
189
|
-
var cmd;
|
|
190
|
-
|
|
191
|
-
script = readFileSync( resolve( __dirname, 'fixtures', 'stdin_error.js.txt' ), {
|
|
192
|
-
'encoding': 'utf8'
|
|
193
|
-
});
|
|
194
|
-
|
|
195
|
-
// Replace single quotes with double quotes:
|
|
196
|
-
script = replace( script, '\'', '"' );
|
|
197
|
-
|
|
198
|
-
cmd = [
|
|
199
|
-
EXEC_PATH,
|
|
200
|
-
'-e',
|
|
201
|
-
'\''+script+'\''
|
|
202
|
-
];
|
|
203
|
-
|
|
204
|
-
opts = {
|
|
205
|
-
'cwd': __dirname
|
|
206
|
-
};
|
|
207
|
-
|
|
208
|
-
exec( cmd.join( ' ' ), opts, done );
|
|
209
|
-
|
|
210
|
-
function done( error, stdout, stderr ) {
|
|
211
|
-
if ( error ) {
|
|
212
|
-
t.pass( error.message );
|
|
213
|
-
t.strictEqual( error.code, 1, 'expected exit code' );
|
|
214
|
-
}
|
|
215
|
-
t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' );
|
|
216
|
-
t.strictEqual( stderr.toString(), 'Error: beep\n', 'expected value' );
|
|
217
|
-
t.end();
|
|
218
|
-
}
|
|
219
|
-
});
|