Skip to content

Commit 77e154e

Browse files
committed
Provide both esm and commonjs
Update typescript to 4.8.3 and jasmine to 4.4.0
1 parent 241a53c commit 77e154e

13 files changed

+360
-171
lines changed

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
node_modules/
22
index.js
3-
index.d.ts
3+
index.d.ts
4+
commonjs/index.js

.npmignore

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,6 @@ test/
44
.git*
55
*.ts
66
!*.d.ts
7-
tsconfig.json
7+
tsconfig.json
8+
tsconfig.base.json
9+
tsconfig.commonjs.json

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## v0.3.1 (2022-09-16)
4+
- Now provides both esm and cjs builds
5+
- Update TypeScript to 4.8.3
6+
37
## v0.3.0 (2019-04-16)
48
**Dev Experience Changes**
59
- Project now compiled with TypeScript and provides typings

commonjs/package.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"type": "commonjs"
3+
}

index.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
2-
export { parseArgsStringToArgv as default, parseArgsStringToArgv };
3-
function parseArgsStringToArgv(
1+
export { parseArgsStringToArgv };
2+
export default function parseArgsStringToArgv(
43
value: string,
54
env?: string,
65
file?: string

package-lock.json

+177-38
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+14-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "string-argv",
33
"description": "string-argv parses a string into an argument array to mimic process.argv. This is useful when testing Command Line Utilities that you want to pass arguments to.",
4-
"version": "0.3.0",
4+
"version": "0.3.1",
55
"contributors": [
66
{
77
"name": "Michael Ferris",
@@ -17,11 +17,20 @@
1717
"argv"
1818
],
1919
"scripts": {
20-
"build": "tsc -p .",
20+
"build": "tsc -p . & tsc -p tsconfig.commonjs.json",
2121
"prepublishOnly": "npm test",
2222
"test": "npm run build & jasmine --config=test/config.json"
2323
},
24-
"main": "index",
24+
"type": "module",
25+
"exports": {
26+
".": {
27+
"types": "./index.d.ts",
28+
"import": "./index.js",
29+
"require": "./commonjs/index.js"
30+
}
31+
},
32+
"main": "./commonjs/index.js",
33+
"module": "./index.js",
2534
"types": "index.d.ts",
2635
"engines": {
2736
"node": ">=0.6.19"
@@ -35,9 +44,8 @@
3544
},
3645
"homepage": "https://github.com/mccormicka/string-argv",
3746
"readmeFilename": "README.md",
38-
"dependencies": {},
3947
"devDependencies": {
40-
"jasmine": "^2.4.1",
41-
"typescript": "^3.4.3"
48+
"jasmine": "^4.4.0",
49+
"typescript": "^4.8.3"
4250
}
4351
}

test/Index.spec.cjs

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
"use strict";
2+
var {default: StringArgv, parseArgsStringToArgv} = require("..");
3+
4+
5+
describe("Require", function () {
6+
it("should correctly import both from default and from named export", function () {
7+
expect(StringArgv).not.toBeNull();
8+
expect(StringArgv).toBeInstanceOf(Function);
9+
expect(StringArgv.length).toBe(3);
10+
11+
expect(parseArgsStringToArgv).not.toBeNull();
12+
expect(parseArgsStringToArgv).toBeInstanceOf(Function);
13+
expect(parseArgsStringToArgv.length).toBe(3);
14+
15+
expect(parseArgsStringToArgv).toBe(StringArgv);
16+
});
17+
});
18+

0 commit comments

Comments
 (0)