Skip to content

Commit cf18c1b

Browse files
committed
Finalize changes
1 parent 680c570 commit cf18c1b

9 files changed

Lines changed: 16 additions & 20 deletions

File tree

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,4 +131,5 @@ dist
131131
.pnp.*
132132

133133
# node-gyp
134-
build/
134+
build/
135+
lib/

binding.gyp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"targets":
33
[
44
{
5-
"target_name": "sevenzip-node",
5+
"target_name": "sevenzip",
66
"cflags!": [ "-fno-exceptions" ],
77
"cflags_cc!": [ "-fno-exceptions", "-std=c++17" ],
88
"conditions":

docs/compress.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Compress a whole directory or some files. If the destination exists, it will be
88
- `dir` `<String>`: directory to compress. Cannot be with `files` as the same time. _(global)_
99
- `files` `<Array>`: files to compress. Cannot be with `dir` as the same time. _(**Windows** only)_
1010
- `destination` `<String>`: directory or new archive file path. You can use a directory if `dir` is use. _(global)_
11-
- `level` `<Number>`: compression level to use. Only accept: -1, 0, 1, 3, 5, 7, 9. You can use the [CompressionLevel](https://github.com/SteezCram/sevenzip-node/blob/main/docs/CompressionLevel.md) enum. _(`7z` and `zip` only)_
11+
- `level` `<Number>`: compression level to use. Only accept: -1, 0, 1, 3, 5, 7, 9. You can use the [CompressionLevel](https://github.com/SteezCram/sevenzip/blob/main/docs/CompressionLevel.md) enum. _(`7z` and `zip` only)_
1212
- `password` `<String>`: password to use to compress the archive. _(`7z` only)_
1313
- `is64` `<Boolean>`: use Deflate64 or Deflate. _(`zip` only)_
1414
- `callback` `<Function>`

index.js

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ module.exports.CompressionLevel = {
2424
*
2525
* @return {promise} - pending operation
2626
*/
27-
module.exports.compress = async function (algorithm, parameters, callback, progressCallback)
27+
module.exports.compress = function (algorithm, parameters, callback, progressCallback)
2828
{
2929
if (!parameters)
3030
throw 'Parameters cannot be undefined or null';
@@ -33,19 +33,14 @@ module.exports.compress = async function (algorithm, parameters, callback, progr
3333

3434
algorithm = (algorithm === '' || algorithm === null || algorithm === undefined) ? '7z' : algorithm;
3535

36-
try {
37-
await fs.promises.access(parameters.destination);
38-
39-
if (await fs.promises.lstat(parameters.destination).isDirectory()) {
36+
if (fs.existsSync(parameters.destination)) {
37+
if (fs.lstatSync(parameters.destination).isDirectory()) {
4038
if (parameters.dir === undefined)
4139
throw 'Destination is a directory';
4240

4341
parameters.destination = path.join(parameters.destination, `${path.basename(parameters.dir)}.${algorithm}`);
4442
}
4543
}
46-
catch {
47-
// No error, the destination need to be created
48-
}
4944

5045

5146
switch (process.platform)

lib/win32/x64/sevenzip-node.node

-595 KB
Binary file not shown.

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"url": "git://github.com/SteezCram/sevenzip.git"
99
},
1010
"binary": {
11-
"module_name": "@steezcram/sevenzip",
11+
"module_name": "sevenzip",
1212
"module_path": "./lib/{platform}/{arch}",
1313
"host": "undefined"
1414
},

src/main.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
/// <param name="info">Parameters passed</param>
1919
///
2020
/// <returns>Undefined value</returns>
21-
inline Napi::Value Compress (const Napi::CallbackInfo& info)
21+
inline Napi::Value Compress(const Napi::CallbackInfo& info)
2222
{
2323
std::string algorithm = info[0].ToString();
2424

@@ -54,7 +54,7 @@ inline Napi::Value Compress (const Napi::CallbackInfo& info)
5454
/// <param name="info">Parameters passed</param>
5555
///
5656
/// <returns>Undefined value</returns>
57-
inline Napi::Value Extract (const Napi::CallbackInfo& info)
57+
inline Napi::Value Extract(const Napi::CallbackInfo& info)
5858
{
5959
std::string algorithm = info[0].ToString();
6060

test/module.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ const sevenZip = require('../index');
66

77

88
// TO CHANGE TO FIT WITH YOUR TEST !!!
9-
const DIR_TO_COMPRESS = 'C:\\Users\\tcroi\\Desktop\\DCSB-4.0.0.9';
10-
const DESTINATION = 'C:\\Users\\tcroi\\Desktop\\';
9+
const DIR_TO_COMPRESS = 'C:\\Users\\thomas\\Desktop\\HWInfo';
10+
const DESTINATION = 'C:\\Users\\thomas\\Desktop\\';
1111

1212

1313
describe('compression test', function()

0 commit comments

Comments
 (0)