mirror of
https://github.com/docsifyjs/docsify.git
synced 2026-10-16 20:21:38 +08:00
show an example that works without deasync (run with node --experimental-specifier-resolution=node .eslintrc.cjs)
This commit is contained in:
+11
-10
@@ -1,23 +1,22 @@
|
||||
const deasync = require('deasync'); // powerful magic
|
||||
main();
|
||||
|
||||
const promiseSync = deasync((promise, cb) => {
|
||||
console.log('wait for promise, before');
|
||||
promise
|
||||
async function main() {
|
||||
|
||||
const importSync = name =>
|
||||
// promiseSync(
|
||||
import(name)
|
||||
.then(result => {
|
||||
console.log('promise resolved');
|
||||
cb(null, result);
|
||||
return result;
|
||||
})
|
||||
.catch(error => {
|
||||
console.log('promise error');
|
||||
cb(error);
|
||||
});
|
||||
});
|
||||
|
||||
const importSync = name => promiseSync(import(name));
|
||||
// );
|
||||
|
||||
// Look, no await needed here!
|
||||
console.log('import sync before');
|
||||
const jestConfig = importSync('./jest.config.js').default;
|
||||
const jestConfig = (await importSync('./jest.config')).default;
|
||||
console.log('import sync after');
|
||||
|
||||
const testGlobals = {};
|
||||
@@ -102,3 +101,5 @@ module.exports = {
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
import path from 'path';
|
||||
import server from './test/config/server.js';
|
||||
import server from './test/config/server';
|
||||
|
||||
console.log('jest.config');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user