diff --git a/README.md b/README.md
index f414fd6..faac16f 100644
--- a/README.md
+++ b/README.md
@@ -8,7 +8,7 @@ _Copy or rename a file (CLI tool designed for use in npm scripts)_
[](https://snyk.io/test/github/center-key/copy-file-util)
[](https://github.com/center-key/copy-file-util/actions/workflows/run-spec-on-push.yaml)
-**copy-file-util** takes a source file and copies it to a new destination. The console output includes a timestamp and formatting helpful in build systems.
+**copy-file-util** takes a source file and copies it to a new destination. The command's console output includes a timestamp and formatting helpful in build systems.
@@ -46,10 +46,11 @@ $ copy-file src/web/api.html docs/api-manual.html
### 3. CLI Flags
Command-line flags:
-| Flag | Description | Values | Default |
-| ---------- | --------------------------------- | ------ | ------- |
-| `--folder` | Indicates the target is a folder. | N/A | N/A |
-| `--quiet` | Suppress informational messages. | N/A | N/A |
+| Flag | Description | Values |
+| ---------- | ---------------------------------------------- | ---------- |
+| `--cd` | Change working directory before starting copy. | **string** |
+| `--folder` | Indicates the target is a folder. | N/A |
+| `--quiet` | Suppress informational messages. | N/A |
Examples:
- `copy-file app.js app.mjs --quite` Displays no output.
@@ -71,9 +72,10 @@ See the **TypeScript Declarations** at the top of [copy-file.ts](copy-file.ts) f
---
**Build Tools**
- - 🎋 [add-dist-header](https://github.com/center-key/add-dist-header): _Prepend a one-line header comment (with license notice) to distribution files_
+ - 🎋 [add-dist-header](https://github.com/center-key/add-dist-header): _Prepend a one-line banner comment (with license notice) to distribution files_
- 📄 [copy-file-util](https://github.com/center-key/copy-file-util): _Copy or rename a file (CLI tool designed for use in npm scripts)_
- 📂 [copy-folder-cli](https://github.com/center-key/copy-folder-cli): _Recursively copy a folder (CLI tool designed for use in npm scripts)_
+ - 🔢 [rev-web-assets](https://github.com/center-key/rev-web-assets): _Revision web asset filenames with cache busting content hash fingerprints_
- 🚦 [w3c-html-validator](https://github.com/center-key/w3c-html-validator): _Check the markup validity of HTML files using the W3C validator_
Feel free to submit questions at:
diff --git a/dist/copy-file.d.ts b/dist/copy-file.d.ts
index 6aa1268..0197ad2 100644
--- a/dist/copy-file.d.ts
+++ b/dist/copy-file.d.ts
@@ -1,11 +1,12 @@
-//! copy-file-util v0.1.2 ~~ https://github.com/center-key/copy-file-util ~~ MIT License
+//! copy-file-util v0.1.3 ~~ https://github.com/center-key/copy-file-util ~~ MIT License
-export declare type Options = {
- cd?: string;
- targetFile?: string;
- targetFolder?: string;
- fileExtension?: string;
+export declare type Settings = {
+ cd: string;
+ targetFile: string;
+ targetFolder: string;
+ fileExtension: string;
};
+export declare type Options = Partial;
export declare type Result = {
origin: string;
dest: string;
diff --git a/dist/copy-file.js b/dist/copy-file.js
index 7fcc9e1..b238d0e 100644
--- a/dist/copy-file.js
+++ b/dist/copy-file.js
@@ -1,6 +1,6 @@
-//! copy-file-util v0.1.2 ~~ https://github.com/center-key/copy-file-util ~~ MIT License
+//! copy-file-util v0.1.3 ~~ https://github.com/center-key/copy-file-util ~~ MIT License
-import fs from 'fs-extra';
+import fs from 'fs';
import path from 'path';
import slash from 'slash';
const copyFile = {
@@ -19,7 +19,7 @@ const copyFile = {
const normalize = (folder) => !folder ? '' : slash(path.normalize(folder)).replace(/\/$/, '');
const startFolder = settings.cd ? normalize(settings.cd) + '/' : '';
const source = sourceFile ? normalize(startFolder + sourceFile) : '';
- const sourceExists = source && fs.pathExistsSync(source);
+ const sourceExists = source && fs.existsSync(source);
const sourceIsFile = sourceExists && fs.statSync(source).isFile();
const sourceFilename = sourceIsFile ? path.basename(source) : null;
const targetPath = settings.targetFile ? path.dirname(settings.targetFile) : settings.targetFolder;
@@ -27,8 +27,8 @@ const copyFile = {
const targetFile = (_a = settings.targetFile) !== null && _a !== void 0 ? _a : settings.targetFolder + '/' + sourceFilename;
const target = normalize(startFolder + targetFile);
if (targetFolder)
- fs.ensureDirSync(targetFolder);
- const badTargetFolder = !targetFolder || !fs.pathExistsSync(targetFolder);
+ fs.mkdirSync(targetFolder, { recursive: true });
+ const badTargetFolder = !targetFolder || !fs.existsSync(targetFolder);
const errorMessage = settings.fileExtension ? 'Option "fileExtension" not yet implemented.' :
!sourceFile ? 'Must specify the source file.' :
!sourceExists ? 'Source file does not exist: ' + source :
@@ -39,7 +39,7 @@ const copyFile = {
null;
if (errorMessage)
throw Error('[copy-file-util] ' + errorMessage);
- fs.copySync(source, target);
+ fs.copyFileSync(source, target);
return {
origin: source,
dest: target,
diff --git a/dist/copy-file.umd.cjs b/dist/copy-file.umd.cjs
index 9a01754..4e19d51 100644
--- a/dist/copy-file.umd.cjs
+++ b/dist/copy-file.umd.cjs
@@ -1,4 +1,4 @@
-//! copy-file-util v0.1.2 ~~ https://github.com/center-key/copy-file-util ~~ MIT License
+//! copy-file-util v0.1.3 ~~ https://github.com/center-key/copy-file-util ~~ MIT License
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
@@ -9,13 +9,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
if (v !== undefined) module.exports = v;
}
else if (typeof define === "function" && define.amd) {
- define(["require", "exports", "fs-extra", "path", "slash"], factory);
+ define(["require", "exports", "fs", "path", "slash"], factory);
}
})(function (require, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.copyFile = void 0;
- const fs_extra_1 = __importDefault(require("fs-extra"));
+ const fs_1 = __importDefault(require("fs"));
const path_1 = __importDefault(require("path"));
const slash_1 = __importDefault(require("slash"));
const copyFile = {
@@ -34,16 +34,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
const normalize = (folder) => !folder ? '' : (0, slash_1.default)(path_1.default.normalize(folder)).replace(/\/$/, '');
const startFolder = settings.cd ? normalize(settings.cd) + '/' : '';
const source = sourceFile ? normalize(startFolder + sourceFile) : '';
- const sourceExists = source && fs_extra_1.default.pathExistsSync(source);
- const sourceIsFile = sourceExists && fs_extra_1.default.statSync(source).isFile();
+ const sourceExists = source && fs_1.default.existsSync(source);
+ const sourceIsFile = sourceExists && fs_1.default.statSync(source).isFile();
const sourceFilename = sourceIsFile ? path_1.default.basename(source) : null;
const targetPath = settings.targetFile ? path_1.default.dirname(settings.targetFile) : settings.targetFolder;
const targetFolder = targetPath ? normalize(startFolder + targetPath) : null;
const targetFile = (_a = settings.targetFile) !== null && _a !== void 0 ? _a : settings.targetFolder + '/' + sourceFilename;
const target = normalize(startFolder + targetFile);
if (targetFolder)
- fs_extra_1.default.ensureDirSync(targetFolder);
- const badTargetFolder = !targetFolder || !fs_extra_1.default.pathExistsSync(targetFolder);
+ fs_1.default.mkdirSync(targetFolder, { recursive: true });
+ const badTargetFolder = !targetFolder || !fs_1.default.existsSync(targetFolder);
const errorMessage = settings.fileExtension ? 'Option "fileExtension" not yet implemented.' :
!sourceFile ? 'Must specify the source file.' :
!sourceExists ? 'Source file does not exist: ' + source :
@@ -54,7 +54,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
null;
if (errorMessage)
throw Error('[copy-file-util] ' + errorMessage);
- fs_extra_1.default.copySync(source, target);
+ fs_1.default.copyFileSync(source, target);
return {
origin: source,
dest: target,
diff --git a/package.json b/package.json
index 34a1296..5a695c2 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "copy-file-util",
- "version": "0.1.2",
+ "version": "0.1.3",
"description": "Copy or rename a file (CLI tool designed for use in npm scripts)",
"license": "MIT",
"type": "module",