Skip to content

Commit

Permalink
feat: return reload modules array
Browse files Browse the repository at this point in the history
  • Loading branch information
cxtom committed Jul 27, 2020
1 parent 70b9ced commit 5fc017c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,10 @@ export default class Reloader {
}
}
this.updateFileMap(Object.assign(this.fileMap, newFileMap));
return errors;
return {
reloadModules: Array.from(reloadModules),
errors,
};
}

updateFileMap(fileMap: IFileMap) {
Expand Down
5 changes: 3 additions & 2 deletions test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,18 @@ describe('Reloader test', () => {
expect(require('./fixtures/mod1').num).to.be.equal(2);
expect(require('./fixtures/mod2').num).to.be.equal(3);

let errors = reloader.reload({
let {errors, reloadModules} = reloader.reload({
mod1: '2',
});

expect(errors.length).to.be.equal(0);
expect(reloadModules.length).to.be.equal(1);
expect(require('./fixtures/mod1').num).to.be.equal(1);
expect(require('./fixtures/mod2').num).to.be.equal(3);

errors = reloader.reload({
mod2: '3',
});
}).errors;
expect(require('./fixtures/mod1').num).to.be.equal(1);
expect(require('./fixtures/mod2').num).to.be.equal(2);
});
Expand Down

0 comments on commit 5fc017c

Please sign in to comment.