Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sleexyz/reloady
node code auto reload
https://github.com/sleexyz/reloady
browser-testing debugging hot-reload livecoding
Last synced: 1 day ago
JSON representation
node code auto reload
- Host: GitHub
- URL: https://github.com/sleexyz/reloady
- Owner: sleexyz
- Created: 2018-01-28T03:22:55.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2018-02-01T22:06:09.000Z (almost 7 years ago)
- Last Synced: 2024-10-10T18:23:15.064Z (28 days ago)
- Topics: browser-testing, debugging, hot-reload, livecoding
- Language: JavaScript
- Homepage:
- Size: 47.9 KB
- Stars: 3
- Watchers: 3
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Reloady
[![CircleCI](https://circleci.com/gh/sleexyz/reloady.svg?style=svg)](https://circleci.com/gh/sleexyz/reloady)
[![npm version](https://img.shields.io/npm/v/reloady.svg?style=flat-square)](https://www.npmjs.com/package/reloady)Automatically re-execute code when it changes, from anywhere in your code.
Great for:
- checkpointing while debugging slow tests (think browser tests)
- live-coding with node.js![reloady buddy](https://user-images.githubusercontent.com/1505617/35489842-be91bb66-0468-11e8-88e8-babe130ac3a2.png)
## Usage
```
yarn add --dev reloady
```Reloady can be initialized anywhere in your code. Just give it:
1. an absolute path to a module with a function as a default export
2. an optional argument to call the function withExample:
```js
const reloady = require("reloady");(async () => {
const foo = 1;
const bar = 2;await reloady({
path: require.resolve("./debug"),
input: { foo, bar }
});})();
```Reloady returns a promise that never resolves, so you can `await` it as a sort of persistent debugger.
---
Now every time you change `./debug.js`, the module will be re-required and re-invoked with its given arguments.
```js
// ./debug.jsmodule.exports = async ({ foo, bar }) => {
console.log(foo); // 1
await new Promise(resolve => setTimeout(resolve, 1000));
console.log(bar); // 2
}
```