Skip to content

Commit

Permalink
Release v0.1.3
Browse files Browse the repository at this point in the history
  • Loading branch information
dpilafian committed Oct 4, 2022
1 parent 48b6911 commit 6b19f70
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 27 deletions.
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ _Copy or rename a file (CLI tool designed for use in npm scripts)_
[![Vulnerabilities](https://snyk.io/test/github/center-key/copy-file-util/badge.svg)](https://snyk.io/test/github/center-key/copy-file-util)
[![Build](https://github.com/center-key/copy-file-util/workflows/build/badge.svg)](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.

<img src=https://raw.githubusercontent.com/center-key/copy-file-util/main/screenshot.png
width=800 alt=screenshot>
Expand Down Expand Up @@ -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` &nbsp; Displays no output.
Expand All @@ -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):&nbsp; _Prepend a one-line header comment (with license notice) to distribution files_
- 🎋 [add-dist-header](https://github.com/center-key/add-dist-header):&nbsp; _Prepend a one-line banner comment (with license notice) to distribution files_
- 📄 [copy-file-util](https://github.com/center-key/copy-file-util):&nbsp; _Copy or rename a file (CLI tool designed for use in npm scripts)_
- 📂 [copy-folder-cli](https://github.com/center-key/copy-folder-cli):&nbsp; _Recursively copy a folder (CLI tool designed for use in npm scripts)_
- 🔢 [rev-web-assets](https://github.com/center-key/rev-web-assets):&nbsp; _Revision web asset filenames with cache busting content hash fingerprints_
- 🚦 [w3c-html-validator](https://github.com/center-key/w3c-html-validator):&nbsp; _Check the markup validity of HTML files using the W3C validator_

Feel free to submit questions at:<br>
Expand Down
13 changes: 7 additions & 6 deletions dist/copy-file.d.ts
Original file line number Diff line number Diff line change
@@ -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<Settings>;
export declare type Result = {
origin: string;
dest: string;
Expand Down
12 changes: 6 additions & 6 deletions dist/copy-file.js
Original file line number Diff line number Diff line change
@@ -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 = {
Expand All @@ -19,16 +19,16 @@ 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;
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.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 :
Expand All @@ -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,
Expand Down
16 changes: 8 additions & 8 deletions dist/copy-file.umd.cjs
Original file line number Diff line number Diff line change
@@ -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 };
Expand All @@ -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 = {
Expand All @@ -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 :
Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down

0 comments on commit 6b19f70

Please sign in to comment.