我一直在寻找一个真正的例子,但我找不到任何例子。我对 node js 完全陌生。
我正在设置一个使用命令行工具获取密码的服务。
命令行“pw get key”返回与密钥关联的密码。命令行“pw set key password”设置与密钥关联的密码。
到目前为止,我拥有的部分代码是:
const util = require('util');
const exec = util.promisify(require('child_process').exec);
async function cmdPwGet(key) {
const { stdout, stderr } = await exec(`pw get ${key}`);
console.log('stdout:', stdout);
console.log('stderr:', stderr);
}
async function cmdPwPut(key, passwd) {
const { stdout, stderr } = await exec(`pw set ${key} ${passwd}`);
console.log('stdout:', stdout);
console.log('stderr:', stderr);
}
class PwService {
constructor (KEY){
this.basekey = KEY;
this.pwd = "";
}
setPw (key, passwd) {
key = this.basekey + …Run Code Online (Sandbox Code Playgroud) 我有一个 DisplayNameDemo.java 文件,如下所示
显示名称演示程序
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
@DisplayName("A special test case")
public class DisplayNameDemo {
@Test
@DisplayName("Custom test name containing spaces")
void testWithDisplayNameContainingSpaces() {
}
@Test
@DisplayName("?°?°??")
void testWithDisplayNameContainingSpecialCharacters() {
}
@Test
@DisplayName(" ")
void testWithDisplayNameContainingEmoji() {
}
}
Run Code Online (Sandbox Code Playgroud)
然后我将它编译为 .class 文件使用
javac -cp .:junit-platform-console-standalone-1.0.0.jar DisplayNameDemo.java
Run Code Online (Sandbox Code Playgroud)
这个命令执行成功?我得到了一个 DisplayNameDemo.class 文件。
之后,我运行了如下所示的命令
java -jar junit-platform-console-standalone-1.0.0.jar --select-class DisplayNameDemo.class
Run Code Online (Sandbox Code Playgroud)
但它失败了并说“org.junit.platform.commons.util.PreconditionViolationException:无法加载名称为:DisplayNameDemo.class的类”
请帮帮我,非常感谢!
我希望其他人之前也遇到过这个问题..我在终端中使用 npm start 来运行我的反应项目,该项目通过 localhost:3000 打开,但是我在终端中编写的任何以下命令都不会执行!我希望能够通过 npm start 使用初始化我的项目,在我的文本编辑器中进行更改,然后通过终端将更改提交到 GitHub。任何帮助将不胜感激!谢谢
我有一个脚本可以在 macOS 上检查证书的身份。
security find-identity -v | grep my-cert.test.com
Run Code Online (Sandbox Code Playgroud)
结果是:
1) 13DB7FSDF188E2C4454KK33E5E0A7B4LK6714658 "my-cert.test.com"
2) 5L56971E29DFA20LHD5E2CEA9DF6J7C46C2D0FD5 "my-cert.test.com"
3) JS34KL78LG620CJKMDFBV5K1K56MNCL9M6SD61L "my-cert.test.com"`
Run Code Online (Sandbox Code Playgroud)
用来awk拉只是身份
security find-identity -v | grep my-cert.test.com | awk '{ print $2}’
Run Code Online (Sandbox Code Playgroud)
结果是:
13DB7FSDF188E2C4454KK33E5E0A7B4LK6714658
5L56971E29DFA20LHD5E2CEA9DF6J7C46C2D0FD5
JS34KL78LG620CJKMDFBV5K1K56MNCL9M6SD61L
Run Code Online (Sandbox Code Playgroud)
这意味着我有 3 个证书,并且awk我已将其余证书分开,并在多个结果之间使用空格拉出身份。现在我想将上述grep结果设置在一个变量中。如果grep结果是 3 行,如上所述,将它们设置在不同的变量中。我知道我可以将其放入单个变量中,var=$(...)但我希望将结果分开。
例子:
ONE=13DB7FSDF188E2C4454KK33E5E0A7B4LK6714658
TWO=5L56971E29DFA20LHD5E2CEA9DF6J7C46C2D0FD5
THREE=JS34KL78LG620CJKMDFBV5K1K56MNCL9M6SD61I4
Run Code Online (Sandbox Code Playgroud)
如果更多,请继续。
我需要这个,以便我可以在进一步的脚本中使用这些变量。所述grep输出可以是线,1个或更多的任意数量。
我试图在 CLI 中找出我在 Linux Ubuntu 中知道的命令,但我需要在 Microsoft 中应用它。
此外,我试图在具有特定名称的文件夹中查找所有文件。特别是,我尝试查找名称中包含术语“测试”的所有文件。这是我在 Linux 中知道的命令:
find \home\user\data -name '*test*'
Run Code Online (Sandbox Code Playgroud)
有谁知道 Windows 命令行中的等价物?
我正在探索 docker,我一直在使用 Windows Powershell ISE 来运行 docker 命令。我遇到过在 Powershell 中运行某些命令但它们似乎卡住的情况,但是当我在命令提示符上运行相同的 docker 命令时,它们工作正常。我使用的是同一台机器但不同的命令行工具。为什么某些 docker 命令可以在 powershell 中工作而有些则不能?下面只是一些例子。虽然大多数工作,但有些似乎没有工作。
示例 1) docker system prune
在 powershell 中,我期望在下面的命令提示符中显示一条消息,但它似乎挂了。
示例 2) docker exec -ti containerName bash
在 CMD Prompt 中,我可以跳入正在运行的容器,但不能跳入 Powershell
powershell command-line command-prompt docker docker-command
在 NPM 项目中,我想为每个构建版本提交一个提交。这将使我能够返回到当前的构建版本,修复错误,而无需通过新版本的所有 QA。
我们可以使用这样的 npm 脚本进行提交(请参阅此答案):
包.json
"scripts": {
"git": "git add . && git commit -m",
}
Run Code Online (Sandbox Code Playgroud)
然后通过运行来调用脚本:
npm run git -- "Message of the commit"
Run Code Online (Sandbox Code Playgroud)
我想在 npm run build 之后自动运行它。为此,我们可以创建一个新命令。
包.json
npm run git -- "Message of the commit"
Run Code Online (Sandbox Code Playgroud)
这可以使用运行 npm run buildAndCommit -- "commit for a new build"
唯一剩下的就是我想将此提交标识为可以链接到提交的提交。是否可以使用“ BUILD -”自动启动消息并将在命令行中传递的唯一消息添加到该消息中?就像是:
包.json
"scripts": {
"buildAndCommit": "npm run build && git add . && git commit -m",
}
Run Code Online (Sandbox Code Playgroud)
如果无法在package.json 中对字符串进行模板化,我如何使用命令行脚本来实现它?(Powershell 是我的命令行工具)。
我正在使用从源到目标的 Robocopy。
以下将移动所有文件。
Step 1: robocopy c:\Source C:\Destination /MIR
Run Code Online (Sandbox Code Playgroud)
现在,当我逐步执行第二个命令时,应该使用 /MIR 参数从目标中删除 2019 年 1 月 1 日之前的任何内容,但是这不会发生(2019 年 1 月之后的文件仍保留在文件夹中,而不是使用 /MIR 命令删除)。我将如何解决这个问题?在 20190101 之前删除任何东西?
Step 2: robocopy c:\Source C:\Destination /MIR /maxage:19000101 /minage:20190101"
Run Code Online (Sandbox Code Playgroud) 我正在构建一个 npm 包,我希望它使用自己的命令运行。
假设我的包的名称是hello-world并且它在 package.json 中有一个名为start的脚本,该脚本运行:
node index.js
Run Code Online (Sandbox Code Playgroud)
我想要的是从命令行能够编写一些将运行此脚本的自定义命令。
例如,写hello-world在cmdwill do 中npm run start。
一个很好的例子是nodemon包。
我是 python 初学者,在运行以下命令时遇到问题:
git clone https://github.com/marksgraham/OCT-Converter.git
Run Code Online (Sandbox Code Playgroud)
( https://github.com/marksgraham/OCT-Converter )
我已经在我的 Mac 上安装了 Python 3.7.4 并绑定到在 IDLE 中运行它。但它说“SyntaxError:无效语法”关于“克隆”。我是否需要先安装其他东西才能运行它?
command-line ×10
powershell ×3
node.js ×2
npm ×2
awk ×1
bash ×1
docker ×1
exec ×1
git ×1
github ×1
java ×1
junit ×1
junit5 ×1
macos ×1
npm-scripts ×1
npm-start ×1
python-3.x ×1
python-idle ×1
robocopy ×1
shell ×1
terminal ×1
testcafe ×1
testing ×1
windows ×1