Skip to content

Commit

Permalink
Release v0.0.4
Browse files Browse the repository at this point in the history
  • Loading branch information
dpilafian committed Aug 16, 2023
1 parent 6b81bcc commit 5687f5a
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 18 deletions.
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,13 @@ The command template supports 4 variables:
| `{{basename}}` | Relative path including filename without the file extension. | `'libraries/d3'` |
| `{{path}}` | Relative path without filename. | `'libraries'` |

### 2. Using with npx
### 2. Command-line npx
Example terminal command to minimize JavaScript files:
```shell
$ npm install --save-dev recursive-exec
$ npx recursive-exec build/web --ext=.js "uglifyjs {{file}} --output dist/web/{{basename}}.min.js"
```

You can also install **recursive-exec** globally and then run it anywhere directly from the terminal.
You can also install **recursive-exec** globally (`--global`) and then run it anywhere directly from the terminal.

### 3. CLI flags
Command-line flags:
Expand Down
2 changes: 1 addition & 1 deletion dist/recursive-exec.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! recursive-exec v0.0.3 ~~ https://github.com/center-key/recursive-exec ~~ MIT License
//! recursive-exec v0.0.4 ~~ https://github.com/center-key/recursive-exec ~~ MIT License

export type Settings = {
extensions: string[] | null;
Expand Down
4 changes: 2 additions & 2 deletions dist/recursive-exec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! recursive-exec v0.0.3 ~~ https://github.com/center-key/recursive-exec ~~ MIT License
//! recursive-exec v0.0.4 ~~ https://github.com/center-key/recursive-exec ~~ MIT License

import { globSync } from 'glob';
import { spawnSync } from 'node:child_process';
Expand Down Expand Up @@ -48,7 +48,7 @@ const recursiveExec = {
command: interpolate(command),
};
};
const results = files.map(calcResult);
const results = files.map(slash).map(calcResult);
const execCommand = (result) => {
if (!settings.quiet)
log(logName, chalk.blue.bold('command:'), chalk.cyanBright(result.command));
Expand Down
16 changes: 9 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "recursive-exec",
"version": "0.0.3",
"version": "0.0.4",
"description": "Run a command on each file in a folder and its subfolders (CLI tool designed for use in npm scripts)",
"license": "MIT",
"type": "module",
Expand Down Expand Up @@ -68,15 +68,17 @@
"clean": [
"rimraf build dist spec/fixtures/target"
],
"build": [
"lint": [
"jshint . --exclude-path .gitignore",
"eslint --max-warnings 0 . --ext .ts",
"eslint --max-warnings 0 . --ext .ts"
],
"build": [
"tsc",
"add-dist-header build dist"
]
},
"scripts": {
"pretest": "run-scripts clean build",
"pretest": "run-scripts clean lint build",
"test": "mocha spec/*.spec.js --timeout 7000"
},
"dependencies": {
Expand All @@ -88,9 +90,9 @@
},
"devDependencies": {
"@types/fancy-log": "~2.0",
"@types/node": "~20.4",
"@typescript-eslint/eslint-plugin": "~6.3",
"@typescript-eslint/parser": "~6.3",
"@types/node": "~20.5",
"@typescript-eslint/eslint-plugin": "~6.4",
"@typescript-eslint/parser": "~6.4",
"add-dist-header": "~1.2",
"assert-deep-strict-equal": "~1.1",
"csso-cli": "~4.0",
Expand Down
8 changes: 3 additions & 5 deletions spec/mocha.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { assertDeepStrictEqual } from 'assert-deep-strict-equal';
import { cliArgvUtil } from 'cli-argv-util';
import assert from 'assert';
import fs from 'fs';
import slash from 'slash';

// Setup
import { recursiveExec } from '../dist/recursive-exec.js';
Expand Down Expand Up @@ -109,11 +108,10 @@ describe('Correct error is thrown', () => {
////////////////////////////////////////////////////////////////////////////////
describe('Executing the CLI', () => {
const run = (posix) => cliArgvUtil.run(pkg, posix);
const readFiles = (folder) => fs.readdirSync(folder, { recursive: true }).map(slash).sort();

it('to compile LESS files to CSS preserves the source folder structure', () => {
run('recursive-exec spec/fixtures/source --ext=.less "lessc {{file}} spec/fixtures/target/css/{{basename}}.css"');
const actual = readFiles('spec/fixtures/target/css');
const actual = cliArgvUtil.readFiles('spec/fixtures/target/css');
const expected = [
'mock1.css',
'subfolder',
Expand All @@ -125,7 +123,7 @@ describe('Executing the CLI', () => {
it('to optimize CSS files preserves the source folder structure', () => {
run('recursive-exec spec/fixtures/source --ext=.js "make-dir spec/fixtures/target/css-min/{{path}}" --quiet');
run('recursive-exec spec/fixtures/target/css "csso {{file}} --output spec/fixtures/target/css-min/{{basename}}.min.css"');
const actual = readFiles('spec/fixtures/target/css-min');
const actual = cliArgvUtil.readFiles('spec/fixtures/target/css-min');
const expected = [
'mock1.min.css',
'subfolder',
Expand All @@ -137,7 +135,7 @@ describe('Executing the CLI', () => {
it('to minimize JS files preserves the source folder structure', () => {
run('recursive-exec spec/fixtures/source --ext=.js --quiet "make-dir spec/fixtures/target/js/{{path}}"');
run('recursive-exec spec/fixtures/source --ext=.js "uglifyjs {{file}} --output spec/fixtures/target/js/{{basename}}.min.js"');
const actual = readFiles('spec/fixtures/target/js');
const actual = cliArgvUtil.readFiles('spec/fixtures/target/js');
const expected = [
'mock1.min.js',
'subfolder',
Expand Down

0 comments on commit 5687f5a

Please sign in to comment.