Skip to content

Commit 49d3982

Browse files
authored
feat: support cjs and esm both by tshy (#2)
BREAKING CHANGE: drop Node.js < 18.19.0 support part of eggjs/egg#3644 eggjs/egg#5257
1 parent e47a73b commit 49d3982

File tree

14 files changed

+239
-2581
lines changed

14 files changed

+239
-2581
lines changed

.eslintrc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"extends": [
3+
"eslint-config-egg/typescript",
4+
"eslint-config-egg/lib/rules/enforce-node-prefix"
5+
]
6+
}

.github/workflows/nodejs.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
pull_request:
7+
branches: [ master ]
8+
9+
jobs:
10+
Job:
11+
name: Node.js
12+
uses: node-modules/github-actions/.github/workflows/node-test.yml@master
13+
with:
14+
version: '18.19.0, 18, 20, 22, 23'
15+
secrets:
16+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

.github/workflows/pkg.pr.new.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Publish Any Commit
2+
on: [push, pull_request]
3+
4+
jobs:
5+
build:
6+
runs-on: ubuntu-latest
7+
8+
steps:
9+
- name: Checkout code
10+
uses: actions/checkout@v4
11+
12+
- run: corepack enable
13+
- uses: actions/setup-node@v4
14+
with:
15+
node-version: 20
16+
17+
- name: Install dependencies
18+
run: npm install
19+
20+
- name: Build
21+
run: npm run prepublishOnly --if-present
22+
23+
- run: npx pkg-pr-new publish

.github/workflows/release.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
7+
jobs:
8+
release:
9+
name: Node.js
10+
uses: node-modules/github-actions/.github/workflows/node-release.yml@master
11+
secrets:
12+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
13+
GIT_TOKEN: ${{ secrets.GIT_TOKEN }}

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
11
node_modules
2+
.tshy*
3+
.eslintcache
4+
dist
25
coverage
6+
package-lock.json

.travis.yml

Lines changed: 0 additions & 13 deletions
This file was deleted.
File renamed without changes.

LICENSE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
MIT License
22

33
Copyright (C) 2012 by fent
4+
Copyright (C) 2024 - present node-modules
45

56
Permission is hereby granted, free of charge, to any person obtaining a copy
67
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,25 @@
1-
# muk-prop.js
1+
# @cnpmjs/muk-prop
22

3-
[![Build Status](https://secure.travis-ci.org/fent/muk-prop.js.svg)](http://travis-ci.org/fent/muk-prop.js)
4-
[![Dependency Status](https://david-dm.org/fent/muk-prop.js.svg)](https://david-dm.org/fent/muk-prop.js)
5-
[![codecov](https://codecov.io/gh/fent/muk-prop.js/branch/master/graph/badge.svg)](https://codecov.io/gh/fent/muk-prop.js)
3+
[![NPM version][npm-image]][npm-url]
4+
[![Node.js CI](https://github.com/node-modules/muk-prop.js/actions/workflows/nodejs.yml/badge.svg)](https://github.com/node-modules/muk-prop.js/actions/workflows/nodejs.yml)
5+
[![codecov](https://codecov.io/gh/node-modules/muk-prop.js/graph/badge.svg?token=YuWQxJfyk2)](https://codecov.io/gh/node-modules/muk-prop.js)
6+
[![npm download][download-image]][download-url]
7+
[![Node.js Version](https://img.shields.io/node/v/@cnpmjs/muk-prop.svg?style=flat)](https://nodejs.org/en/download/)
8+
9+
[npm-image]: https://img.shields.io/npm/v/@cnpmjs/muk-prop.svg?style=flat-square
10+
[npm-url]: https://npmjs.org/package/@cnpmjs/muk-prop
11+
[download-image]: https://img.shields.io/npm/dm/@cnpmjs/muk-prop.svg?style=flat-square
12+
[download-url]: https://npmjs.org/package/@cnpmjs/muk-prop
613

714
![muk](muk.gif)
815

9-
# Usage
16+
## Usage
1017

1118
Object method mocking.
1219

1320
```js
1421
const fs = require('fs');
15-
const muk = require('muk-prop');
22+
const { muk } = require('@cnpmjs/muk-prop');
1623

1724
muk(fs, 'readFile', (path, callback) => {
1825
process.nextTick(callback.bind(null, null, 'file contents here'));
@@ -22,7 +29,7 @@ muk(fs, 'readFile', (path, callback) => {
2229
Object props mocking with setter/getter.
2330

2431
```js
25-
const muk = require('muk-prop');
32+
const { muk } = require('@cnpmjs/muk-prop');
2633

2734
const obj = { _a: 1 };
2835
muk(obj, 'a', {
@@ -37,28 +44,37 @@ console.log(obj.a); // 4
3744
Check if member has been mocked.
3845

3946
```js
40-
muk.isMocked(fs, 'readFile'); // true
47+
const { isMocked } = require('@cnpmjs/muk-prop');
48+
49+
isMocked(fs, 'readFile'); // true
4150
```
4251

4352
Restore all mocked methods/props after tests.
4453

4554
```js
46-
muk.restore();
55+
const { restore } = require('@cnpmjs/muk-prop');
4756

4857
fs.readFile(file, (err, data) => {
4958
// will actually read from `file`
5059
});
5160
```
5261

62+
## Install
5363

54-
# Install
55-
56-
npm install muk-prop
64+
```bash
65+
npm install @cnpmjs/muk-prop
66+
```
5767

68+
## Tests
5869

59-
# Tests
6070
Tests are written with [mocha](https://mochajs.org)
6171

6272
```bash
6373
npm test
6474
```
75+
76+
## Contributors
77+
78+
[![Contributors](https://contrib.rocks/image?repo=node-modules/muk-prop.js)](https://github.com/node-modules/muk-prop.js/graphs/contributors)
79+
80+
Made with [contributors-img](https://contrib.rocks).

0 commit comments

Comments
 (0)