Posts 常用vscode配置和git命令备忘
Post
Cancel

常用vscode配置和git命令备忘

  记录下需要容易忘记但又常用的vscode配置和git命令.

Git 命令行

撤销一次 Pull 操作

git revert --hard head

撤销最近一次 Commit 操作

git reset HEAD~1

删除分支

  • 删除远程分支 git push origin -d <branchName>
  • 删除本地分支 git branch -d <branchName>

VScode 配置

在VS Code 中调试前端项目

首先我们得npm start启动我们的前端项目

url 这个参数需要改动的是你本地项目启动的端口

webRoot 这个参数是前端项目的入口文件的路径, 配置完毕后 Debug 启动就能在 VS Code 中打断点调试了

1
2
3
4
5
6
7
{
  "name": "Debug Launch React Program",
  "request": "launch",
  "type": "pwa-chrome",
  "url": "http://localhost:3000",
  "webRoot": "${workspaceFolder}/src/index.js" 
}

在VS Code 中调试Node.js后端项目

program 这个参数是后端项目的入口文件的路径, 配置完毕后 Debug 启动就能在 VS Code 中打断点调试了

1
2
3
4
5
6
7
8
9
{
  "name": "Debug Launch Express Program",
  "program": "${workspaceFolder}/index.js",
  "request": "launch",
  "skipFiles": [
    "<node_internals>/**"
  ],
  "type": "pwa-node"
}

调试Jest测试框架的某个单元测试TS文件

1
2
3
4
5
6
7
8
9
10
11
12
13
{
  "type": "node",
  "name": "Debug Jest Test",
  "request": "launch",
  "args": [
    "--runInBand"
  ],
  "cwd": "${workspaceFolder}",
  "console": "integratedTerminal",
  "internalConsoleOptions": "neverOpen",
  "disableOptimisticBPs": true,
  "program": "${workspaceFolder}/node_modules/jest/bin/jest"
}

调试Mocha测试框架的某个单元测试TS文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
{
  "type": "node",
  "request": "launch",
  "name": "Debug Mocha Test",
  "program": "${workspaceFolder}/node_modules/mocha/bin/_mocha",
  "args": [
    "-r",
    "ts-node/register",
    "--timeout",
    "999999",
    "--colors",
    "${workspaceFolder}/${relativeFile}"
  ],
  "env": { "TS_NODE_COMPILER_OPTIONS": "{\"module\": \"commonjs\"}" },
  "envFile": "${workspaceFolder}/../.env",
  "protocol": "inspector"
}

调试Mocha测试框架的某个单元测试JS文件

1
2
3
4
5
6
7
8
9
{
  "type": "node",
  "request": "launch",
  "name": "Mocha Current File",
  "program": "${workspaceFolder}/node_modules/mocha/bin/_mocha",
  "args": ["--timeout", "999999", "--colors", "${file}"],
  "console": "integratedTerminal",
  "internalConsoleOptions": "neverOpen"
}

调试Mocha测试框架的某个文件夹的所以单元测试JS文件

1
2
3
4
5
6
7
8
9
{
  "type": "node",
  "request": "launch",
  "name": "Mocha All",
  "program": "${workspaceFolder}/node_modules/mocha/bin/_mocha",
  "args": ["--timeout", "999999", "--colors", "${workspaceFolder}/test"],
  "console": "integratedTerminal",
  "internalConsoleOptions": "neverOpen"
}

调试当前TS文件

1
2
3
4
5
6
7
8
{
  "type": "node",
  "request": "launch",
  "name": "Debug Current File",
  "program": "${workspaceFolder}/${relativeFile}",
  "preLaunchTask": "tsc: build - tsconfig.json",
  "outFiles": ["${workspaceFolder}/dist/**/*.js"]
}

调试当前JS文件

1
2
3
4
5
6
7
8
9
{
  "type": "node",
  "request": "launch",
  "name": "Current JS File",
  "skipFiles": [
      "<node_internals>/**"
  ],
  "program": "${relativeFile}"
}

continuous update…

This post is licensed under CC BY 4.0 by the author.

初识node.js并发

一次复杂的需求的存储过程实现代码