gzl的博客

  • 首页

  • 关于

  • 标签

  • 分类

  • 归档

一些使用过的npm包

发表于 2019-10-22 更新于 2020-03-03 分类于 node.js

concurrently

https://www.npmjs.com/package/concurrently

使用 concurrently 可以实现前后端用一个命令启动

1
npm install concurrently

目录结构为后端文件中包含一个 client 文件夹为前端代码。详情看 vue-fund-manage 项目结构。

后端 package.json 文件下配置 script

1
2
3
4
5
6
7
"scripts": {
"client-install": "npm intall --prefix client",
"client": "npm start --prefix client",
"start": "node server.js",
"server": "supervisor server.js",
"dev": "concurrent \"npm run server\" \"npm run client\""
}

前端 package.json 文件下配置 script

1
2
3
4
5
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"start": "npm run serve"
}

最后使用下面的命令就可以一起启动前后端。

1
npm run dev

supervisor

https://www.npmjs.com/package/supervisor

在开发过程中,每次修改代码保存后,我们都需要手动重启程序,才能查看改动的效果。使用 supervisor 可以解决这个繁琐的问题,全局安装 supervisor:

1
npm i -g supervisor

开启

1
supervisor index.js

supervisor 会监听当前目录下 node 和 js 后缀的文件,当这些文件发生改动时,supervisor 会自动重启程序。

1
2
3
4
5
6
Node Supervisor is used to restart programs when they crash.
It can also be used to restart programs when a *.js file changes.

Usage:
supervisor [options] <program>
supervisor [options] -- <program> [args ...]

http-server

https://www.npmjs.com/package/http-server

使用 http-server 可以快速开启一个小型的node静态服务。

1
npm install http-server -g

开启

1
2
3
4
5
http-server

hs # 快捷方式

usage: http-server [path] [options]

fanyi

https://www.npmjs.com/package/fanyi

安装

1
npm install fanyi -g

使用:直接在命令行里输入想翻译的词即可 fy 是简写,完整写法是 fanyi。

1
$ fy love

git open

https://www.npmjs.com/package/git-open

安装

1
npm install --global git-open

使用:在一次 git push 之后,运行

1
git open

即可打开该项目的网页地址。

git-常用操作小结

发表于 2019-10-19 更新于 2020-02-12 分类于 git

退出 git log

在英文状态下按 q

git clone 重命名

如何重命名仓库,对当前文件夹已经存在同名仓库的时候会很有用:

1
git clone git@github.com:muwenzi/repo.git new-repo-name

git rm

有时候在项目开发过程中,把某些目录或文件加入.gitignore后发现并未生效,原因是.gitignore只能忽略那些原来没有被track的文件,如果某些文件已经被纳入了版本管理中,则修改.gitignore是无效的。那么解决方法就是先把本地缓存删除(改变成未track状态),然后再提交:

1
2
3
git rm -r --cached .
git add .
git commit -m 'update .gitignore

.gitignore 的匹配规则:

1
2
3
4
5
.a       # 忽略所有 .a 结尾的文件
!lib.a # 但 lib.a 除外
/TODO # 仅仅忽略项目根目录下的 TODO 文件,不包括 subdir/TODO
build/ # 忽略 build/ 目录下的所有文件
doc/.txt # 会忽略 doc/notes.txt 但不包括 doc/server/arch.txt

更改 git commit 注释

git add . ,git commit -m "wrong explanatory" 之后还没有 git push , 发现 git commit 的注释写错了。

这个时候输入 git commit --amend,会自动打开 vim 编辑器,按 a 进入编辑模式,将正确的注释写入,然后按 ESC 键,输入 :wq 进行保存并退出,然后 git push。

github仓库更改名字后

1
2
3
4
# 更改github仓库名称后在本地进行git push出现下面提示,在这种情况下github也能同步
remote: This repository moved. Please use the new location:
remote: git@github.com:xunzhanggzl/JavaScript-demos.git
To github.com:xunzhanggzl/JavaScript-Summary.git

查看当前名称

1
2
3
git remote -v
origin git@github.com:xunzhanggzl/JavaScript-Summary.git (fetch)
origin git@github.com:xunzhanggzl/JavaScript-Summary.git (push)

进行 set-url

1
2
3
git remote set-url origin https://github.com/YOUR-USERNAME/YOUR-REPO.git
# 换成自己的
git remote set-url origin https://github.com/xunzhanggzl/JavaScript-demos.git

修改后再查看,以后再进行 git push 就不会出现上面的提示了。

1
2
3
git remote -v
origin https://github.com/xunzhanggzl/JavaScript-demos.git (fetch)
origin https://github.com/xunzhanggzl/JavaScript-demos.git (push)

参考

Git常用操作小结

github仓库改名后的处理

快捷键

发表于 2019-10-13 更新于 2020-03-03 分类于 快捷键

快捷键总结

chrome

打开新标签页

1
Ctrl + T

关闭当前页

1
Ctrl + W

金山词霸

打开/关闭

1
Alt + M

win10

返回桌面

1
win + D

打开文件资源管理器

1
win + E

快速锁屏

1
win + L

窗口最小化\最大化切换

1
win + ↓\↑

切换输入法

1
win + 空格

打开任务栏上第n个程序

1
win + 数字键

打开任务管理器

1
Ctrl + Shift + Esc

关闭当前窗口

1
Ctrl + W

搜索

1
win + Q

VSCode

打开项目所在目录

1
Shift + Alt + R

格式化代码

1
Shift + Alt + F

多行注释

1
Shift + Alt + A

搜索目录下的文件

1
Ctrl + P

terminal

打开 testforgit 文件

1
E:\>start testforgit
1…91011…32

gzl

96 日志
14 分类
37 标签
© 2020 gzl
由 Hexo 强力驱动 v3.7.1
|
主题 – NexT.Pisces v7.2.0