知识杂记
- vim 批量替换: %s/username/login_name/g
- git 创建附注 tag : git tag -a v0.1.2 -m “0.1.2版本”
- git 推送本地 tag 到远端:git push --tags
- Mac 查看隐藏文件 command + shift + .
- 文本超长 css 样式设置
max-width: 150px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
- fs 复制文件夹
function copyFolder(copiedPath, resultPath) { if (fs.existsSync(copiedPath)) { const files = fs.readdirSync(copiedPath, { withFileTypes: true }); for (let i = 0; i < files.length; i++) { const cf = files[i]; const ccp = path.join(copiedPath, cf.name); const crp = path.join(resultPath, cf.name); if (cf.isFile()) { const readStream = fs.createReadStream(ccp); const writeStream = fs.createWriteStream(crp); readStream.pipe(writeStream); } } } else { console.log('do not exist path: ', copiedPath); } }
- js 中文的正则匹配 \u4e00-\u9fa5,所以文件名由中文,数字,字母,下划线,连字符,空格,中英文括号,小数点构成且长度小于255的正则是
/^[.()()\sa-zA-Z0-9_\u4e00-\u9fa5-]{1,255}$/
(’\s’是空格,’\u4e00-\u9fa5’是中文) - a 标签的 href 要和 rel=“noopener noreferrer” 一起用,保证安全,eslint 的 jsx-no-target-blank