Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

新增node download下的下载判断以及中文路径错误的修正 #106

Merged
merged 3 commits into from
Oct 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 38 additions & 24 deletions examples/node/just-task.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,42 @@
const { task, logger } = require('just-scripts')
const download = require('download')
const path = require('path')

task('install', () => {
const { task, logger } = require("just-scripts");
const download = require("download");
const path = require("path");
task("install", () => {
return new Promise((resolve, reject) => {
const localPath = path.join(__dirname, 'lib')
var platform = process.env.npm_config_target_platform || process.platform
logger.info(`[install] Target platform: ${platform}`)
if (platform === 'darwin') {
platform = 'osx';
} else if (platform === 'win32') {
platform = 'windows';
const localPath = path.join(__dirname, "lib");
var platform = process.env.npm_config_target_platform || process.platform;
var arch = process.env.npm_config_target_arch || process.arch;

let downloadUrl = `https://github.com/wangfenjin/simple/releases/latest/download/libsimple-linux-ubuntu-18.04.zip`;
if (platform === "darwin") {
platform = "osx";
downloadUrl = `https://github.com/wangfenjin/simple/releases/latest/download/libsimple-osx-x64.zip`;
} else if (platform === "win32") {
platform = "windows";
if (arch === "x64") {
downloadUrl = `https://github.com/wangfenjin/simple/releases/latest/download/libsimple-windows-x64.zip`;
} else {
downloadUrl = `https://github.com/wangfenjin/simple/releases/latest/download/libsimple-windows-x86.zip`;
}
}
var arch = process.env.npm_config_target_arch || process.arch
logger.info(`[install] Target arch: ${arch}`)
const downloadUrl = `https://github.com/wangfenjin/simple/releases/download/v0.2.0-alpha/libsimple-linux-ubuntu-18.04.zip`
logger.info(`[install] Download prebuilt binaries from ${downloadUrl}`)

logger.info(`[install] Target platform: -${platform}-`);
logger.info(`[install] Target arch: ${arch}`);
logger.info(`[install] Download prebuilt binaries from ${downloadUrl}`);


download(downloadUrl, localPath, {
extract: true, strip: 1
}).then(() => {
resolve()
}).catch(err => {
logger.warn(`[install] Failed to download package from: ${downloadUrl}, err: ${err}`)
reject()
extract: true,
strip: 1,
})
})
})
.then(() => {
resolve();
})
.catch((err) => {
logger.warn(
`[install] Failed to download package from: ${downloadUrl}, err: ${err}`
);
reject();
});
});
});
2 changes: 1 addition & 1 deletion examples/node/node-sqlite3.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ db.serialize(function() {
if (argv('ext_path')) {
ext_path = argv('ext_path');
}
var dict_path = path.join(ext_path, "dict");
var dict_path = "./lib/dict";
if (argv('dict_path')) {
dict_path = argv('dict_path');
}
Expand Down
Loading