├── .npmrc ├── .gitattributes ├── .gitignore ├── .editorconfig ├── test.js ├── .github └── workflows │ └── main.yml ├── cli.js ├── readme.md ├── license └── package.json /.npmrc: -------------------------------------------------------------------------------- 1 | package-lock=false 2 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto eol=lf 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | yarn.lock 3 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | indent_style = tab 5 | end_of_line = lf 6 | charset = utf-8 7 | trim_trailing_whitespace = true 8 | insert_final_newline = true 9 | 10 | [*.yml] 11 | indent_style = space 12 | indent_size = 2 13 | -------------------------------------------------------------------------------- /test.js: -------------------------------------------------------------------------------- 1 | import fs from 'node:fs'; 2 | import test from 'ava'; 3 | import execa from 'execa'; 4 | import tempy from 'tempy'; 5 | 6 | test('main', async t => { 7 | const sourceFile = tempy.file(); 8 | const destinationFile = tempy.file(); 9 | fs.writeFileSync(sourceFile, '🦄'); 10 | await execa('./cli.js', [sourceFile, destinationFile]); 11 | t.is(fs.readFileSync(destinationFile, 'utf8'), '🦄'); 12 | }); 13 | -------------------------------------------------------------------------------- /.github/workflows/main.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | on: 3 | - push 4 | - pull_request 5 | jobs: 6 | test: 7 | name: Node.js ${{ matrix.node-version }} 8 | runs-on: ubuntu-latest 9 | strategy: 10 | fail-fast: false 11 | matrix: 12 | node-version: 13 | - 16 14 | steps: 15 | - uses: actions/checkout@v2 16 | - uses: actions/setup-node@v2 17 | with: 18 | node-version: ${{ matrix.node-version }} 19 | - run: npm install 20 | - run: npm test 21 | -------------------------------------------------------------------------------- /cli.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | import meow from 'meow'; 3 | import {moveFileSync} from 'move-file'; 4 | 5 | const cli = meow(` 6 | Usage 7 | $ move-file 8 | 9 | Options 10 | --no-overwrite Don't overwrite an existing destination file 11 | 12 | Example 13 | $ move-file source/unicorn.png destination/unicorn.png 14 | `, { 15 | importMeta: import.meta, 16 | flags: { 17 | overwrite: { 18 | type: 'boolean', 19 | default: true, 20 | }, 21 | }, 22 | }); 23 | 24 | const [source, destination] = cli.input; 25 | 26 | moveFileSync(source, destination, cli.flags); 27 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # move-file-cli 2 | 3 | > Move a file on the command-line 4 | 5 | This is a simpler and cross-platform alternative to `mv` for build scripts, etc. 6 | 7 | Note: It only handles a single file at the time. It does not handle directories. 8 | 9 | ## Install 10 | 11 | ```sh 12 | npm install --global move-file-cli 13 | ``` 14 | 15 | ## Usage 16 | 17 | ``` 18 | move-file --help 19 | 20 | Usage 21 | $ move-file 22 | 23 | Options 24 | --no-overwrite Don't overwrite an existing destination file 25 | 26 | Example 27 | $ move-file source/unicorn.png destination/unicorn.png 28 | ``` 29 | 30 | ## Related 31 | 32 | - [move-file](https://github.com/sindresorhus/move-file) - API for this module 33 | - [cpy-cli](https://github.com/sindresorhus/cpy-cli) - Copy files on the command-line 34 | -------------------------------------------------------------------------------- /license: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) Sindre Sorhus (https://sindresorhus.com) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "move-file-cli", 3 | "version": "3.0.0", 4 | "description": "Move a file on the command-line", 5 | "license": "MIT", 6 | "repository": "sindresorhus/move-file-cli", 7 | "funding": "https://github.com/sponsors/sindresorhus", 8 | "author": { 9 | "name": "Sindre Sorhus", 10 | "email": "sindresorhus@gmail.com", 11 | "url": "https://sindresorhus.com" 12 | }, 13 | "type": "module", 14 | "bin": { 15 | "move-file": "./cli.js" 16 | }, 17 | "engines": { 18 | "node": "^12.20.0 || ^14.13.1 || >=16.0.0" 19 | }, 20 | "scripts": { 21 | "test": "xo && ava" 22 | }, 23 | "files": [ 24 | "cli.js" 25 | ], 26 | "keywords": [ 27 | "cli-app", 28 | "cli", 29 | "move", 30 | "file", 31 | "mv", 32 | "fs", 33 | "stream", 34 | "file-system", 35 | "ncp", 36 | "fast", 37 | "quick", 38 | "data", 39 | "content", 40 | "contents", 41 | "devices", 42 | "partitions" 43 | ], 44 | "dependencies": { 45 | "meow": "^10.1.1", 46 | "move-file": "^3.0.0" 47 | }, 48 | "devDependencies": { 49 | "ava": "^3.15.0", 50 | "execa": "^5.1.1", 51 | "tempy": "^1.0.1", 52 | "xo": "^0.44.0" 53 | } 54 | } 55 | --------------------------------------------------------------------------------