Compare commits
5 Commits
Author | SHA1 | Date | |
---|---|---|---|
3d30f41f84 | |||
9abe66c830 | |||
61dbf9680b | |||
a45fcf016e | |||
4e04843e0e |
@ -1,6 +1,7 @@
|
|||||||
{
|
{
|
||||||
"npmci": {
|
"npmci": {
|
||||||
"npmGlobalTools": []
|
"npmGlobalTools": [],
|
||||||
|
"npmAccessLevel": "public"
|
||||||
},
|
},
|
||||||
"gitzone": {
|
"gitzone": {
|
||||||
"projectType": "npm",
|
"projectType": "npm",
|
||||||
|
2
package-lock.json
generated
2
package-lock.json
generated
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "smartarchive",
|
"name": "smartarchive",
|
||||||
"version": "1.0.8",
|
"version": "1.0.11",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@pushrocks/smartarchive",
|
"name": "@pushrocks/smartarchive",
|
||||||
"version": "1.0.8",
|
"version": "1.0.11",
|
||||||
"description": "work with archives",
|
"description": "work with archives",
|
||||||
"main": "dist_ts/index.js",
|
"main": "dist_ts/index.js",
|
||||||
"typings": "dist_ts/index.d.ts",
|
"typings": "dist_ts/index.d.ts",
|
||||||
|
10
test/test.ts
10
test/test.ts
@ -11,13 +11,15 @@ const testPlugins = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const testPaths = {
|
const testPaths = {
|
||||||
nogitDir: testPlugins.path.join(process.cwd(), '.nogit/')
|
nogitDir: testPlugins.path.join(process.cwd(), '.nogit/'),
|
||||||
|
remoteDir: testPlugins.path.join(process.cwd(), '.nogit/remote')
|
||||||
};
|
};
|
||||||
|
|
||||||
import * as smartarchive from '../ts/index';
|
import * as smartarchive from '../ts/index';
|
||||||
|
|
||||||
tap.preTask('should prepare .nogit dir', async () => {
|
tap.preTask('should prepare .nogit dir', async () => {
|
||||||
await testPlugins.smartfile.fs.ensureDir(testPaths.nogitDir);
|
await testPlugins.smartfile.fs.ensureDir(testPaths.nogitDir);
|
||||||
|
await testPlugins.smartfile.fs.ensureDir(testPaths.remoteDir);
|
||||||
});
|
});
|
||||||
|
|
||||||
tap.preTask('should prepare downloads', async tools => {
|
tap.preTask('should prepare downloads', async tools => {
|
||||||
@ -40,4 +42,10 @@ tap.test('should extract files on disk', async () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
tap.test('should download a package from the registry', async () => {
|
||||||
|
const testSmartarchive = new smartarchive.SmartArchive();
|
||||||
|
await testSmartarchive.extractArchiveFromUrl('https://verdaccio.lossless.one/@pushrocks%2fsmartfile/-/smartfile-7.0.11.tgz', testPaths.remoteDir);
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
tap.start();
|
tap.start();
|
||||||
|
@ -12,13 +12,10 @@ export class SmartArchive {
|
|||||||
const parsedPath = plugins.path.parse(urlArg);
|
const parsedPath = plugins.path.parse(urlArg);
|
||||||
const uniqueFileName = plugins.smartunique.uni() + parsedPath.ext;
|
const uniqueFileName = plugins.smartunique.uni() + parsedPath.ext;
|
||||||
const downloadPath = plugins.path.join(paths.nogitDir, uniqueFileName);
|
const downloadPath = plugins.path.join(paths.nogitDir, uniqueFileName);
|
||||||
const downloadedArchive = (
|
const downloadedArchive = (await plugins.smartrequest.getBinary(urlArg)).body;
|
||||||
await plugins.smartrequest.getBinary(
|
|
||||||
'https://verdaccio.lossless.one/@pushrocks%2fwebsetup/-/websetup-2.0.14.tgz'
|
|
||||||
)
|
|
||||||
).body;
|
|
||||||
await plugins.smartfile.memory.toFs(downloadedArchive, downloadPath);
|
await plugins.smartfile.memory.toFs(downloadedArchive, downloadPath);
|
||||||
await this.extractArchiveFromFilePath(downloadPath, targetDir);
|
await this.extractArchiveFromFilePath(downloadPath, targetDir);
|
||||||
|
await plugins.smartfile.fs.remove(downloadPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user