# ihaiu-file

> nodejs文件操作

Latest version **1.0.6** (published 2020-03-11) · ISC license · 0 weekly downloads

## Install

```sh
npm install ihaiu-file
pnpm add ihaiu-file
yarn add ihaiu-file
bun add ihaiu-file
```

Provides the command `ihaiu-file`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.6 |
| Published | 2020-03-11 |
| First published | 2020-03-11 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 12.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | zengfeng75@qq.com |
| Maintainers | zengfeng75 |
| Keywords | ihaiu, file, copy |

## Links

- npm: https://www.npmjs.com/package/ihaiu-file
- Repository: https://github.com/ihaiucom/ihaiu.nodejsfile
- Homepage: https://github.com/ihaiucom/ihaiu.nodejsfile#readme
- Issues: https://github.com/ihaiucom/ihaiu.nodejsfile/issues
- npm.io page: https://npm.io/package/ihaiu-file

## Dependencies (1)

- [commander](https://npm.io/package/commander.md) ^4.1.1

## Alternatives

- [unionfs](https://npm.io/package/unionfs.md) — 2.2M weekly downloads
- [path-starts-with](https://npm.io/package/path-starts-with.md) — 35.9K weekly downloads
- [redzip](https://npm.io/package/redzip.md) — 1.2K weekly downloads
- [vscode-anymatch](https://npm.io/package/vscode-anymatch.md) — 848 weekly downloads
- [@ledgerhq/coin-filecoin](https://npm.io/package/@ledgerhq/coin-filecoin.md) — 793 weekly downloads

## Recent versions

- 1.0.6 (latest) — 2020-03-11

## README

# ihaiu.nodejsfile
nodejs 文件操作


* 拷贝文件或目录

```
ihaiu-file -C copy -s ./ -t ./aa/bb/cc     

``` 

* 创建文件夹

```
ihaiu-file -C mkdir -s ./aa/bb/cc/dd   
``` 

* 删除文件或者目录

```
ihaiu-file -C delete -s ./aa/bb/cc/dd
```


* 文件写入

```
ihaiu-file -C write -s ./aaa/bb/a.txt -b "Hello World中午2" -f w  -e utf8
```

* 文件读取

```
ihaiu-file -C read -s ./aaa/bb/a.txt
```



* 文件重命名或者移动文件

```
ihaiu-file -C rename -s ./aa/cc/a.txt -d ./aa/cc/b.txt -o true
```


```
Usage: index [options]

Options:
  -V, --version           output the version number
  -C, --cmd <lang>        命令名称: copy、delete、 mkdir、write、 read、 rename
  -s, --srcpath <path>    路径
  -d, --destpath [path]   拷贝文件目标路径
  -o, --over [boolean]    是否覆盖
  -i, --ignorehide        是否忽略隐藏文件
  -b, --body [lang]       写入文件的内容
  -f, --flag [lang]       写入文件的flag, w, http://nodejs.cn/api/fs.html#fs_file_system_flags
  -e, --encoding  [lang]  默认值: utf8
  -h, --help              output usage information



```















# 学习开发npm笔记
### 创建npm项目
* github创建一个项目clone到本地
* 执行 npm init 命令配置一些paackage.json
```
npm init
```
* 创建一个index.js文件
* 执行 npm login 登录
* 执行 npm publish 推送

### 安装依赖

安装 fs，path等依赖

```
cnpm install @types/node --save-dev
```

安装 命令行依赖
```
cnpm install commander --save
```

### 创建TypeScript项目
* tsc -init
* 修改package.js

```
"main": "bin/index.js",
```

### 编译TypeScript项目

```
tsc
```

### 测试

```
node bin/index.js
```

---
_Source: https://npm.io/package/ihaiu-file · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
