auto-import.js
A tool for automatically update and import NPM module
Usage
Install
npm i @ffee/auto-import --save
AutoImport.require
Require the node module. If the module is not installed, install it automatically before loading it.
const AutoImport = require('@ffee/auto-import');
AutoImport.require('koa').then(koa => {
const app = new koa();
app.use(async ctx => {
ctx.body = 'Hello World!';
});
app.listen(3000);
});
AutoImport.checkModuleUpdateStatus
Check whether the NPM module needs to be updated.
const AutoImport = require('@ffee/auto-import');
AutoImport.checkModuleUpdateStatus('koa').then(res => {
console.log(res);
// {
// name: 'koa',
// status: false,
// message: 'koa had not expired, return current...'
// }
});
LICENSE
MIT.