Skip to content

Commit d319fd0

Browse files
committed
updates restructoring file order, move util functions to single file
1 parent 837f188 commit d319fd0

24 files changed

+606
-747
lines changed

lib/createArchive.mjs

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,8 @@
11
'use strict';
22

33
import when from 'when';
4-
import Files from '../util/files.mjs';
5-
import ReplaceNativeSeparator from '../util/replaceNativeSeparator.mjs';
6-
import Run from '../util/run.mjs';
4+
import { Files, ReplaceNativeSeparator, Run } from './utility.mjs';
75

8-
/**
9-
* Create/add content to an archive.
10-
*
11-
* @param filepath {string} Path to the archive.
12-
* @param files {string|array} Files to add.
13-
* @param options {Object} An object of acceptable 7-zip switch options.
14-
* @param override {boolean} should binary directory change?
15-
*
16-
* @resolve {array} Arguments passed to the child-process.
17-
* @progress {array} Listed files and directories.
18-
* @reject {Error} The error as issued by 7-Zip.
19-
*
20-
* @returns {Promise} Promise
21-
*/
226
export default function (filepath, files, options, override = false) {
237
return when.promise(function (resolve, reject, progress) {
248
/**

lib/createSfx.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
join
1212
} from 'path';
1313
import fs from 'fs-extra';
14-
import binary from '../util/binary.mjs';
14+
import { Binary } from './utility.mjs';
1515

1616
const platformTitle = {
1717
win32: 'Windows OS',
@@ -133,7 +133,7 @@ export default function (
133133
let SfxDirectory = join(directory, 'SfxPackages');
134134
fs.ensureDirSync(SfxDirectory);
135135
let override = ((process.platform == 'win32') && (platform == 'linux' || platform == 'darwin'));
136-
let binaryDirectory = binary(override);
136+
let binaryDirectory = Binary(override);
137137
let configFile = join(binaryDirectory.path, 'config.txt');
138138
//let configFile = join(SfxDirectory, 'config.txt');
139139
let config = fs.createWriteStream(configFile, {

lib/deleteArchive.mjs

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,7 @@
11
'use strict';
22

3-
import Files from '../util/files.mjs';
4-
import Run from '../util/run.mjs';
3+
import { Files, Run } from './utility.mjs';
54

6-
/**
7-
* Delete content from an archive.
8-
*
9-
* @param filepath {string} Path to the archive.
10-
* @param files {string|array} Files to remove.
11-
* @param options {Object} An object of acceptable 7-zip switch options.
12-
* @param override {boolean} should binary directory change?
13-
*
14-
* @resolve {array} Arguments passed to the child-process.
15-
* @reject {Error} The error as issued by 7-Zip.
16-
*
17-
* @returns {Promise} Promise
18-
*/
195
export default function (filepath, files, options, override = false) {
206
return new Promise(function (resolve, reject) {
217

lib/extractArchive.mjs

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,8 @@
11
'use strict';
22

33
import when from 'when';
4-
import ReplaceNativeSeparator from '../util/replaceNativeSeparator.mjs';
5-
import Run from '../util/run.mjs';
4+
import { ReplaceNativeSeparator, Run } from './utility.mjs';
65

7-
/**
8-
* Extract an archive.
9-
*
10-
* @param {string} archive Path to the archive.
11-
* @param {string} dest Destination.
12-
* @param options {Object} An object of acceptable 7-zip switch options.
13-
* @param override {boolean} should binary directory change?
14-
*
15-
* @resolve {array} Arguments passed to the child-process.
16-
* @progress {array} Extracted files and directories.
17-
* @reject {Error} The error as issued by 7-Zip.
18-
*
19-
* @returns {Promise} Promise
20-
*/
216
export default function (filepath, dest = '*', options = {}, override = false) {
227
return when.promise(function (resolve, reject, progress) {
238
/**

lib/fullArchive.mjs

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,8 @@
11
'use strict';
22

33
import when from 'when';
4-
import ReplaceNativeSeparator from '../util/replaceNativeSeparator.mjs';
5-
import Run from '../util/run.mjs';
4+
import { ReplaceNativeSeparator, Run } from './utility.mjs';
65

7-
/**
8-
* Extract an archive with full paths.
9-
*
10-
* @param filepath {string} Path to the archive.
11-
* @param dest {string} Destination.
12-
* @param options {Object} An object of acceptable 7-zip switch options.
13-
* @param override {boolean} should binary directory change?
14-
*
15-
* @resolve {array} Arguments passed to the child-process.
16-
* @progress {array} Extracted files and directories.
17-
* @reject {Error} The error as issued by 7-Zip.
18-
*
19-
* @returns {Promise} Promise
20-
*/
216
export default function (filepath, dest = '*', options = {}, override = false) {
227
return when.promise(function (resolve, reject, progress) {
238
/**

lib/index.d.ts

Lines changed: 0 additions & 82 deletions
This file was deleted.

lib/index.mjs

Lines changed: 121 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,84 @@ import _testArchive from './testArchive.mjs';
1111
import _updateArchive from './updateArchive.mjs';
1212
import createSfx from './createSfx.mjs';
1313

14-
class SevenZip {
15-
constructor() { }
16-
}
14+
function SevenZip() { };
1715

18-
export default SevenZip;
16+
/**
17+
* Create/add content to an archive.
18+
*
19+
* @param filepath {string} Path to the archive.
20+
* @param files {string|array} Files to add.
21+
* @param options {Object} An object of acceptable 7-zip switch options.
22+
* @param override {boolean} should binary directory change?
23+
*
24+
* @resolve {array} Arguments passed to the child-process.
25+
* @progress {array} Listed files and directories.
26+
* @reject {Error} The error as issued by 7-Zip.
27+
*
28+
* @returns {Promise} Promise
29+
*/
1930
export const createArchive = SevenZip.createArchive = _createArchive;
31+
32+
/**
33+
* Delete content from an archive.
34+
*
35+
* @param filepath {string} Path to the archive.
36+
* @param files {string|array} Files to remove.
37+
* @param options {Object} An object of acceptable 7-zip switch options.
38+
* @param override {boolean} should binary directory change?
39+
*
40+
* @resolve {array} Arguments passed to the child-process.
41+
* @reject {Error} The error as issued by 7-Zip.
42+
*
43+
* @returns {Promise} Promise
44+
*/
2045
export const deleteArchive = SevenZip.deleteArchive = _deleteArchive;
46+
47+
/**
48+
* Extract an archive.
49+
*
50+
* @param {string} archive Path to the archive.
51+
* @param {string} dest Destination.
52+
* @param options {Object} An object of acceptable 7-zip switch options.
53+
* @param override {boolean} should binary directory change?
54+
*
55+
* @resolve {array} Arguments passed to the child-process.
56+
* @progress {array} Extracted files and directories.
57+
* @reject {Error} The error as issued by 7-Zip.
58+
*
59+
* @returns {Promise} Promise
60+
*/
2161
export const extractArchive = SevenZip.extractArchive = _extractArchive;
62+
63+
/**
64+
* Extract an archive with full paths.
65+
*
66+
* @param filepath {string} Path to the archive.
67+
* @param dest {string} Destination.
68+
* @param options {Object} An object of acceptable 7-zip switch options.
69+
* @param override {boolean} should binary directory change?
70+
*
71+
* @resolve {array} Arguments passed to the child-process.
72+
* @progress {array} Extracted files and directories.
73+
* @reject {Error} The error as issued by 7-Zip.
74+
*
75+
* @returns {Promise} Promise
76+
*/
2277
export const fullArchive = SevenZip.fullArchive = _fullArchive;
78+
79+
/**
80+
* List contents of archive.
81+
*
82+
* @param filepath {string} Path to the archive.
83+
* @param options {Object} An object of acceptable 7-zip switch options.
84+
* @param override {boolean} should binary directory change?
85+
*
86+
* @progress {array} Listed files and directories.
87+
* @resolve {Object} Tech spec about the archive.
88+
* @reject {Error} The error as issued by 7-Zip.
89+
*
90+
* @returns {Promise} Promise
91+
*/
2392
export const listArchive = SevenZip.listArchive = _listArchive;
2493

2594
/**
@@ -38,8 +107,52 @@ export const listArchive = SevenZip.listArchive = _listArchive;
38107
* @returns {Promise} Promise
39108
*/
40109
export const onlyArchive = SevenZip.onlyArchive = _onlyArchive;
110+
111+
/**
112+
* Renames files in archive.
113+
*
114+
* @param filepath {string} Path to the archive.
115+
* @param files {string} Files pairs to rename in archive.
116+
* @param options {Object} An object of acceptable 7-zip switch options.
117+
* @param override {boolean} should binary directory change?
118+
*
119+
* @resolve {array} Arguments passed to the child-process.
120+
* @progress {array} Listed files and directories.
121+
* @reject {Error} The error as issued by 7-Zip.
122+
*
123+
* @returns {Promise} Promise
124+
*/
41125
export const renameArchive = SevenZip.renameArchive = _renameArchive;
126+
127+
/**
128+
* Test integrity of archive.
129+
*
130+
* @param filepath {string} Path to the archive.
131+
* @param options {Object} An object of acceptable 7-zip switch options.
132+
* @param override {boolean} should binary directory change?
133+
*
134+
* @resolve {array} Arguments passed to the child-process.
135+
* @progress {array} Extracted files and directories.
136+
* @reject {Error} The error as issued by 7-Zip.
137+
*
138+
* @returns {Promise} Promise
139+
*/
42140
export const testArchive = SevenZip.testArchive = _testArchive;
141+
142+
/**
143+
* Update content to an archive.
144+
*
145+
* @param filepath {string} Path to the archive.
146+
* @param files {string} Files to update.
147+
* @param options {Object} An object of acceptable 7-zip switch options.
148+
* @param override {boolean} should binary directory change?
149+
*
150+
* @resolve {array} Arguments passed to the child-process.
151+
* @progress {array} Listed files and directories.
152+
* @reject {Error} The error as issued by 7-Zip.
153+
*
154+
* @returns {Promise} Promise
155+
*/
43156
export const updateArchive = SevenZip.updateArchive = _updateArchive;
44157

45158
export const createSfxWindows = SevenZip.windowsSfx = function (name, files, destination, options, type) {
@@ -53,3 +166,7 @@ export const createSfxLinux = SevenZip.linuxSfx = function (name, files, destina
53166
export const createSfxMac = SevenZip.macSfx = function (name, files, destination, options) {
54167
return createSfx(name, files, destination, options, 'console', 'darwin', '.pkg');
55168
};
169+
170+
export default SevenZip;
171+
172+
export const Zip = SevenZip;

lib/listArchive.mjs

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,8 @@
11
'use strict';
22

33
import when from 'when';
4-
import ReplaceNativeSeparator from '../util/replaceNativeSeparator.mjs';
5-
import Run from '../util/run.mjs';
4+
import { ReplaceNativeSeparator, Run } from './utility.mjs';
65

7-
/**
8-
* List contents of archive.
9-
*
10-
* @param filepath {string} Path to the archive.
11-
* @param options {Object} An object of acceptable 7-zip switch options.
12-
* @param override {boolean} should binary directory change?
13-
*
14-
* @progress {array} Listed files and directories.
15-
* @resolve {Object} Tech spec about the archive.
16-
* @reject {Error} The error as issued by 7-Zip.
17-
*
18-
* @returns {Promise} Promise
19-
*/
206
export default function (filepath, options, override = false) {
217
return when.promise(function (resolve, reject, progress) {
228
let spec = {};

lib/onlyArchive.mjs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
'use strict';
22

33
import when from 'when';
4-
import ReplaceNativeSeparator from '../util/replaceNativeSeparator.mjs';
5-
import Run from '../util/run.mjs';
4+
import { ReplaceNativeSeparator, Run } from './utility.mjs';
65

76
/**
87
* Extract only selected files from archive.

0 commit comments

Comments
 (0)