Skip to content

Commit

Permalink
fix: change exec to execute avoid npm publish security policy
Browse files Browse the repository at this point in the history
…issue
  • Loading branch information
tianyingchun committed Jul 27, 2024
1 parent 9c7dce1 commit e349553
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 34 deletions.
5 changes: 5 additions & 0 deletions .changeset/fluffy-goats-add.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@hyperse/exec-program": patch
---

change `exec` to `execute` avoid npm publish ` security policy` issue
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ dist

# Stores VSCode versions used for testing VSCode extensions
.vscode-test

.DS_Store
# yarn v2
.yarn/cache
.yarn/unplugged
Expand Down
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
</a>
</p>

Execa runs commands in your script, application or library. Unlike shells, it is optimized for programmatic usage.
Runs commands in your script, application or library. Unlike shells, it is optimized for programmatic usage.

## README

Expand Down Expand Up @@ -47,12 +47,12 @@ const { stderr, stdout } = await runTsScript(cliPath);
console.log(stderr, stdout);
```

### exec

import { exec } from '@hyperse/exec-program';
### execute command

```ts
const { stdout, stderr } = await exec(
import { execute } from '@hyperse/exec-program';

const { stdout, stderr } = await execute(
'npm',
['i', '--no-save', '--no-package-lock', ...toInstall],
{
Expand All @@ -64,15 +64,15 @@ const { stdout, stderr } = await exec(
```

```ts
await exec('npm', ['pack', directory], {
await execute('npm', ['pack', directory], {
cwd: this.uniqueDir,
maxBuffer: TEN_MEGA_BYTE,
});
```

#### unit test
#### run ts file for unit testing

1. config `tsconfig.json`
config `tsconfig.json`

```json
{
Expand All @@ -98,7 +98,7 @@ await exec('npm', ['pack', directory], {
]
```

2. create `cli-test.ts`
create `cli-test.ts`

```ts
// cause of `tsconfig.json` we can directly import source .ts file from '@hyperse/exec-program';
Expand All @@ -107,7 +107,7 @@ console.log(typeof runTsScript);
console.log('cli...');
```

3. create exec file `exec.spec.ts`
create test file `main.spec.ts`

```ts
import { dirname, join } from 'node:path';
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@
"@types/node": "^20.14.12",
"commitizen": "4.3.0",
"cz-conventional-changelog": "3.3.0",
"eslint": "^9.7.0",
"husky": "9.1.1",
"eslint": "^9.8.0",
"husky": "9.1.3",
"lint-staged": "15.2.7",
"npm-run-all": "^4.1.5",
"tsup": "^8.2.3",
Expand Down
6 changes: 3 additions & 3 deletions src/exec.ts → src/execute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { ExecOptions, ExecResultPromise } from './types.js';
* Execute a file with arguments and options
* @example
* ```ts
* const { stdout, stderr } = await exec(
* const { stdout, stderr } = await execute(
* 'npm',
* ['i', '--no-save', '--no-package-lock', ...toInstall],
* {
Expand All @@ -17,7 +17,7 @@ import { ExecOptions, ExecResultPromise } from './types.js';
* ```
* @example
* ```ts
* await exec('npm', ['pack', directory], {
* await execute('npm', ['pack', directory], {
* cwd: this.uniqueDir,
* maxBuffer: TEN_MEGA_BYTE,
* });
Expand All @@ -27,7 +27,7 @@ import { ExecOptions, ExecResultPromise } from './types.js';
* @param options - Options to pass to `execa`
* @returns A `ResultPromise` that is both:
*/
export function exec<T extends ExecOptions>(
export function execute<T extends ExecOptions>(
file: string,
args?: readonly string[],
options?: T
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export * from './exec.js';
export * from './execute.js';
export * from './runTsScript.js';
export * from './types.js';
34 changes: 17 additions & 17 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -884,7 +884,7 @@ __metadata:
languageName: node
linkType: hard

"@eslint/config-array@npm:^0.17.0":
"@eslint/config-array@npm:^0.17.1":
version: 0.17.1
resolution: "@eslint/config-array@npm:0.17.1"
dependencies:
Expand Down Expand Up @@ -912,10 +912,10 @@ __metadata:
languageName: node
linkType: hard

"@eslint/js@npm:9.7.0, @eslint/js@npm:^9.5.0":
version: 9.7.0
resolution: "@eslint/js@npm:9.7.0"
checksum: 10/b56b9fdec705f2cefae3a6d9d4227c4c28c5cbdbd8849c7997c357cabd4a729cee4445ddb43bb1423fbeb2280a119ced4d0819be8749d107c511e9d81dfe863a
"@eslint/js@npm:9.8.0, @eslint/js@npm:^9.5.0":
version: 9.8.0
resolution: "@eslint/js@npm:9.8.0"
checksum: 10/1c6ddbcc9f45f0165d9e218c085543536c03b4b650449a6f38f4e2b65b1d6bcd5f24f7feae72fca14d3697073cbdb413f270baef0f744cb0fb9e11ce9c84dbcc
languageName: node
linkType: hard

Expand Down Expand Up @@ -984,9 +984,9 @@ __metadata:
"@types/node": "npm:^20.14.12"
commitizen: "npm:4.3.0"
cz-conventional-changelog: "npm:3.3.0"
eslint: "npm:^9.7.0"
eslint: "npm:^9.8.0"
execa: "npm:^9.3.0"
husky: "npm:9.1.1"
husky: "npm:9.1.3"
lint-staged: "npm:15.2.7"
npm-run-all: "npm:^4.1.5"
tsup: "npm:^8.2.3"
Expand Down Expand Up @@ -3548,15 +3548,15 @@ __metadata:
languageName: node
linkType: hard

"eslint@npm:^9.7.0":
version: 9.7.0
resolution: "eslint@npm:9.7.0"
"eslint@npm:^9.8.0":
version: 9.8.0
resolution: "eslint@npm:9.8.0"
dependencies:
"@eslint-community/eslint-utils": "npm:^4.2.0"
"@eslint-community/regexpp": "npm:^4.11.0"
"@eslint/config-array": "npm:^0.17.0"
"@eslint/config-array": "npm:^0.17.1"
"@eslint/eslintrc": "npm:^3.1.0"
"@eslint/js": "npm:9.7.0"
"@eslint/js": "npm:9.8.0"
"@humanwhocodes/module-importer": "npm:^1.0.1"
"@humanwhocodes/retry": "npm:^0.3.0"
"@nodelib/fs.walk": "npm:^1.2.8"
Expand Down Expand Up @@ -3588,7 +3588,7 @@ __metadata:
text-table: "npm:^0.2.0"
bin:
eslint: bin/eslint.js
checksum: 10/f9b3c99a63f1e94feadb2005d854c907d2a9322d14a0ad8a47a127562475bfdcc43fbffcae184e3de94d832218891bb4b7a21a914f7ef9e22b1d2ee19941368d
checksum: 10/b1dd864170ca359249c92d1d8e09a628497efcf8a4293b571308460125fb0367a15612b2b0f135ff21b92453bf324ce75843fcaac3e01734f4bee2ff79919cc3
languageName: node
linkType: hard

Expand Down Expand Up @@ -4466,12 +4466,12 @@ __metadata:
languageName: node
linkType: hard

"husky@npm:9.1.1":
version: 9.1.1
resolution: "husky@npm:9.1.1"
"husky@npm:9.1.3":
version: 9.1.3
resolution: "husky@npm:9.1.3"
bin:
husky: bin.js
checksum: 10/c3be0392071b78c680fc6b9fd7978f52c26e18238a2840c6eabfc0db395e19fcd798da8eff0e31a9e76c479d6019a567d83a8de80f360d28552bc83bd1839b7c
checksum: 10/35d7ad85a247fb130659ae60b05bca9461820d261d6ff181b55c3dc6f2ae5da5ae3f3807367b90cc85d3bb915a2de8295aa9950e3cba3309994b7763dfd70cb1
languageName: node
linkType: hard

Expand Down

0 comments on commit e349553

Please sign in to comment.