mirror of
https://github.com/bitwarden/cli
synced 2025-12-10 05:13:54 +00:00
Fixes for 1pux importer (#501)
* Pull jslib
* Fixed reading of 1pux files
(cherry picked from commit eb0b844750)
This commit is contained in:
committed by
Daniel James Smith
parent
2295cd3266
commit
34ea8a3ab5
2
jslib
2
jslib
Submodule jslib updated: 813457c348...9aad63f833
37
src/utils.ts
37
src/utils.ts
@@ -48,19 +48,32 @@ export class CliUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static extract1PuxContent(input: string): Promise<string> {
|
static extract1PuxContent(input: string): Promise<string> {
|
||||||
return new JSZip()
|
return new Promise<string>((resolve, reject) => {
|
||||||
.loadAsync(input)
|
let p: string = null;
|
||||||
.then((zip) => {
|
if (input != null && input !== "") {
|
||||||
return zip.file("export.data").async("string");
|
const osInput = path.join(input);
|
||||||
})
|
if (osInput.indexOf(path.sep) === -1) {
|
||||||
.then(
|
p = path.join(process.cwd(), osInput);
|
||||||
function success(content) {
|
} else {
|
||||||
return content;
|
p = osInput;
|
||||||
},
|
|
||||||
function error(e) {
|
|
||||||
return "";
|
|
||||||
}
|
}
|
||||||
);
|
} else {
|
||||||
|
reject("You must specify a file path.");
|
||||||
|
}
|
||||||
|
fs.readFile(p, function (err, data) {
|
||||||
|
if (err) {
|
||||||
|
reject(err);
|
||||||
|
}
|
||||||
|
JSZip.loadAsync(data).then(
|
||||||
|
(zip) => {
|
||||||
|
resolve(zip.file("export.data").async("string"));
|
||||||
|
},
|
||||||
|
(reason) => {
|
||||||
|
reject(reason);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Save the given data to a file and determine the target file if necessary.
|
* Save the given data to a file and determine the target file if necessary.
|
||||||
|
|||||||
Reference in New Issue
Block a user