mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
fix: Fix Windows development environments (no-changelog) (#4720)
This commit is contained in:
committed by
GitHub
parent
07e4743a3e
commit
aec08275aa
@@ -2,25 +2,23 @@
|
|||||||
|
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const glob = require('fast-glob');
|
const glob = require('fast-glob');
|
||||||
const { createContext, Script } = require('vm');
|
|
||||||
const { LoggerProxy } = require('n8n-workflow');
|
const { LoggerProxy } = require('n8n-workflow');
|
||||||
const { packageDir, writeJSON } = require('./common');
|
const { packageDir, writeJSON } = require('./common');
|
||||||
|
const { loadClassInIsolation } = require('../dist/ClassLoader');
|
||||||
|
|
||||||
LoggerProxy.init({
|
LoggerProxy.init({
|
||||||
log: console.log.bind(console),
|
log: console.log.bind(console),
|
||||||
warn: console.warn.bind(console),
|
warn: console.warn.bind(console),
|
||||||
});
|
});
|
||||||
|
|
||||||
const context = Object.freeze(createContext({ require }));
|
|
||||||
const loadClass = (sourcePath) => {
|
const loadClass = (sourcePath) => {
|
||||||
try {
|
try {
|
||||||
const [className] = path.parse(sourcePath).name.split('.');
|
const [className] = path.parse(sourcePath).name.split('.');
|
||||||
const absolutePath = path.resolve(packageDir, sourcePath);
|
const filePath = path.resolve(packageDir, sourcePath);
|
||||||
const script = new Script(`new (require('${absolutePath}').${className})()`);
|
const instance = loadClassInIsolation(filePath, className);
|
||||||
const instance = script.runInContext(context);
|
|
||||||
return { instance, sourcePath, className };
|
return { instance, sourcePath, className };
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
LoggerProxy.warn('Failed to load %s: %s', sourcePath, e.message);
|
LoggerProxy.warn(`Failed to load ${sourcePath}: ${e.message}`);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user