fix: windows load error
Signed-off-by: MiaoWoo <admin@yumc.pw>
This commit is contained in:
parent
1cb4c05efd
commit
48306b64c4
2
pom.xml
2
pom.xml
@ -2,7 +2,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>pw.yumc</groupId>
|
||||
<artifactId>MiaoScript</artifactId>
|
||||
<version>0.11.0</version>
|
||||
<version>0.11.1</version>
|
||||
<developers>
|
||||
<developer>
|
||||
<id>502647092</id>
|
||||
|
@ -57,12 +57,12 @@ var global = this;
|
||||
|
||||
global.start = function (future) {
|
||||
if (!future.isDone()) {
|
||||
logger.info("Waiting MiaoScript booted...")
|
||||
log.info("Waiting MiaoScript booted...")
|
||||
future.get()
|
||||
}
|
||||
logger.info("MiaoScript booted starting...")
|
||||
log.info("MiaoScript booted starting...")
|
||||
global.engineDisableImpl = require(java.lang.System.getenv("MS_NODE_CORE_MODULE") || (global.scope + '/core')).default || function () {
|
||||
logger.info('Error: abnormal Initialization MiaoScript Engine. Skip disable step...')
|
||||
log.info('Error: abnormal Initialization MiaoScript Engine. Skip disable step...')
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -52,6 +52,10 @@
|
||||
// @ts-ignore
|
||||
var URL = Java.type('java.net.URL')
|
||||
// @ts-ignore
|
||||
var Thread = Java.type('java.net.URL')
|
||||
// @ts-ignore
|
||||
var FutureTask = Java.type('java.util.concurrent.FutureTask')
|
||||
// @ts-ignore
|
||||
var JavaString = Java.type('java.lang.String')
|
||||
var separatorChar = File.separatorChar
|
||||
|
||||
@ -301,15 +305,19 @@
|
||||
var info = fetchPackageInfo(module_name)
|
||||
var url = info.versions[ModulesVersionLock[module_name] || info['dist-tags']['latest']].dist.tarball
|
||||
console.log('fetch node_module ' + module_name + ' from ' + url + ' waiting...')
|
||||
var tis = new TarInputStream(new BufferedInputStream(new GZIPInputStream(new URL(url).openStream())))
|
||||
// @ts-ignore
|
||||
var entry
|
||||
while ((entry = tis.getNextEntry()) != null) {
|
||||
var targetPath = Paths.get(target + separatorChar + entry.getName().substring(8))
|
||||
targetPath.toFile().getParentFile().mkdirs()
|
||||
Files.copy(tis, targetPath, StandardCopyOption.REPLACE_EXISTING)
|
||||
}
|
||||
return name
|
||||
var future = new FutureTask(function () {
|
||||
var tis = new TarInputStream(new BufferedInputStream(new GZIPInputStream(new URL(url).openStream())))
|
||||
// @ts-ignore
|
||||
var entry
|
||||
while ((entry = tis.getNextEntry()) != null) {
|
||||
var targetPath = Paths.get(target + separatorChar + entry.getName().substring(8))
|
||||
targetPath.toFile().getParentFile().mkdirs()
|
||||
Files.copy(tis, targetPath, StandardCopyOption.REPLACE_EXISTING)
|
||||
}
|
||||
return name
|
||||
})
|
||||
new Thread(future, "MiaoScript download thread").start()
|
||||
return future.get()
|
||||
}
|
||||
|
||||
/**
|
||||
@ -327,10 +335,14 @@
|
||||
}
|
||||
|
||||
function fetchContent(url, name) {
|
||||
var tempFile = Files.createTempFile(name.replace('/', '_'), '.json')
|
||||
Files.copy(new URL(url).openStream(), tempFile, StandardCopyOption.REPLACE_EXISTING)
|
||||
tempFile.toFile().deleteOnExit()
|
||||
return new JavaString(Files.readAllBytes(tempFile), 'UTF-8')
|
||||
var future = new FutureTask(function () {
|
||||
var tempFile = Files.createTempFile(name.replace('/', '_'), '.json')
|
||||
Files.copy(new URL(url).openStream(), tempFile, StandardCopyOption.REPLACE_EXISTING)
|
||||
tempFile.toFile().deleteOnExit()
|
||||
return new JavaString(Files.readAllBytes(tempFile), 'UTF-8')
|
||||
})
|
||||
new Thread(future, "MiaoScript require thread").start()
|
||||
return future.get()
|
||||
}
|
||||
|
||||
var lastModule = ''
|
||||
|
Loading…
Reference in New Issue
Block a user