feat: auto remove temp file at exit
Signed-off-by: MiaoWoo <admin@yumc.pw>
This commit is contained in:
parent
388e1e9135
commit
c859605738
4
pom.xml
4
pom.xml
@ -3,7 +3,7 @@
|
|||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>pw.yumc</groupId>
|
<groupId>pw.yumc</groupId>
|
||||||
<artifactId>MiaoScript</artifactId>
|
<artifactId>MiaoScript</artifactId>
|
||||||
<version>0.0.1</version>
|
<version>0.1.0</version>
|
||||||
<developers>
|
<developers>
|
||||||
<developer>
|
<developer>
|
||||||
<id>502647092</id>
|
<id>502647092</id>
|
||||||
@ -54,6 +54,8 @@
|
|||||||
<properties>
|
<properties>
|
||||||
<env.GIT_COMMIT>DEV</env.GIT_COMMIT>
|
<env.GIT_COMMIT>DEV</env.GIT_COMMIT>
|
||||||
<update.changes>
|
<update.changes>
|
||||||
|
§619-09-24 §cremove: 移除 okhttp3 类库;
|
||||||
|
§afeat: 新增require自动下载模块功能;
|
||||||
§619-09-21 §afeat: 新增 okhttp3 类库;
|
§619-09-21 §afeat: 新增 okhttp3 类库;
|
||||||
§619-08-31 §afeat: 新增 tar 类库 支持 tar.gz 解压
|
§619-08-31 §afeat: 新增 tar 类库 支持 tar.gz 解压
|
||||||
</update.changes>
|
</update.changes>
|
||||||
|
@ -23,7 +23,6 @@
|
|||||||
* 2. 如果 xx/index.js 存在 则使用 resolveAsFile(xx/index.js) 加载
|
* 2. 如果 xx/index.js 存在 则使用 resolveAsFile(xx/index.js) 加载
|
||||||
* 3. 如果 xx/index.json 存在 则使用 `xx/index.json` 解析为对象加载 并停止执行
|
* 3. 如果 xx/index.json 存在 则使用 `xx/index.json` 解析为对象加载 并停止执行
|
||||||
* 暂不支持 4. 如果 xx/index.msm 是一个文件 则使用MScript解析器解析 并停止执行
|
* 暂不支持 4. 如果 xx/index.msm 是一个文件 则使用MScript解析器解析 并停止执行
|
||||||
* 注: MiaoScript 暂不支持多层 modules 加载 暂时不需要(估计以后也不会需要)
|
|
||||||
*/
|
*/
|
||||||
(function(parent) {
|
(function(parent) {
|
||||||
'use strict';
|
'use strict';
|
||||||
@ -231,9 +230,9 @@
|
|||||||
var name_arr = name.split('/');
|
var name_arr = name.split('/');
|
||||||
var module_name = name.startsWith('@') ? name_arr[0] + '/' + name_arr[1] : name_arr[0];
|
var module_name = name.startsWith('@') ? name_arr[0] + '/' + name_arr[1] : name_arr[0];
|
||||||
// at windows need replace file name java.lang.IllegalArgumentException: Invalid prefix or suffix
|
// at windows need replace file name java.lang.IllegalArgumentException: Invalid prefix or suffix
|
||||||
var tempFile = Files.createTempFile(module_name.replace('/', '_'), 'json');
|
var tempFile = Files.createTempFile(module_name.replace('/', '_'), '.json');
|
||||||
Files.copy(new URL('https://repo.yumc.pw/repository/npm/' + module_name).openStream(), tempFile, StandardCopyOption.REPLACE_EXISTING);
|
Files.copy(new URL('https://repo.yumc.pw/repository/npm/' + module_name).openStream(), tempFile, StandardCopyOption.REPLACE_EXISTING);
|
||||||
var info = JSON.parse(new java.lang.String(Files.readAllBytes(tempFile), 'UTF-8'));
|
var info = JSON.parse(new java.lang.String(Files.readAllBytes(tempFile), 'UTF-8')); tempFile.toFile().deleteOnExit();
|
||||||
var url = info.versions[info['dist-tags']['latest']].dist.tarball;
|
var url = info.versions[info['dist-tags']['latest']].dist.tarball;
|
||||||
console.log('node_module ' + module_name + ' not found at local but exist at internet ' + url + ' downloading...')
|
console.log('node_module ' + module_name + ' not found at local but exist at internet ' + url + ' downloading...')
|
||||||
var tis = new TarInputStream(new BufferedInputStream(new GZIPInputStream(new URL(url).openStream())));
|
var tis = new TarInputStream(new BufferedInputStream(new GZIPInputStream(new URL(url).openStream())));
|
||||||
|
Loading…
Reference in New Issue
Block a user