Skip to content

Commit

Permalink
updates restructoring file order, move util functions to single file
Browse files Browse the repository at this point in the history
  • Loading branch information
TheTechsTech committed Dec 23, 2020
1 parent 837f188 commit d319fd0
Show file tree
Hide file tree
Showing 24 changed files with 606 additions and 747 deletions.
18 changes: 1 addition & 17 deletions lib/createArchive.mjs
Original file line number Diff line number Diff line change
@@ -1,24 +1,8 @@
'use strict';

import when from 'when';
import Files from '../util/files.mjs';
import ReplaceNativeSeparator from '../util/replaceNativeSeparator.mjs';
import Run from '../util/run.mjs';
import { Files, ReplaceNativeSeparator, Run } from './utility.mjs';

/**
* Create/add content to an archive.
*
* @param filepath {string} Path to the archive.
* @param files {string|array} Files to add.
* @param options {Object} An object of acceptable 7-zip switch options.
* @param override {boolean} should binary directory change?
*
* @resolve {array} Arguments passed to the child-process.
* @progress {array} Listed files and directories.
* @reject {Error} The error as issued by 7-Zip.
*
* @returns {Promise} Promise
*/
export default function (filepath, files, options, override = false) {
return when.promise(function (resolve, reject, progress) {
/**
Expand Down
4 changes: 2 additions & 2 deletions lib/createSfx.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
join
} from 'path';
import fs from 'fs-extra';
import binary from '../util/binary.mjs';
import { Binary } from './utility.mjs';

const platformTitle = {
win32: 'Windows OS',
Expand Down Expand Up @@ -133,7 +133,7 @@ export default function (
let SfxDirectory = join(directory, 'SfxPackages');
fs.ensureDirSync(SfxDirectory);
let override = ((process.platform == 'win32') && (platform == 'linux' || platform == 'darwin'));
let binaryDirectory = binary(override);
let binaryDirectory = Binary(override);
let configFile = join(binaryDirectory.path, 'config.txt');
//let configFile = join(SfxDirectory, 'config.txt');
let config = fs.createWriteStream(configFile, {
Expand Down
16 changes: 1 addition & 15 deletions lib/deleteArchive.mjs
Original file line number Diff line number Diff line change
@@ -1,21 +1,7 @@
'use strict';

import Files from '../util/files.mjs';
import Run from '../util/run.mjs';
import { Files, Run } from './utility.mjs';

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

Expand Down
17 changes: 1 addition & 16 deletions lib/extractArchive.mjs
Original file line number Diff line number Diff line change
@@ -1,23 +1,8 @@
'use strict';

import when from 'when';
import ReplaceNativeSeparator from '../util/replaceNativeSeparator.mjs';
import Run from '../util/run.mjs';
import { ReplaceNativeSeparator, Run } from './utility.mjs';

/**
* Extract an archive.
*
* @param {string} archive Path to the archive.
* @param {string} dest Destination.
* @param options {Object} An object of acceptable 7-zip switch options.
* @param override {boolean} should binary directory change?
*
* @resolve {array} Arguments passed to the child-process.
* @progress {array} Extracted files and directories.
* @reject {Error} The error as issued by 7-Zip.
*
* @returns {Promise} Promise
*/
export default function (filepath, dest = '*', options = {}, override = false) {
return when.promise(function (resolve, reject, progress) {
/**
Expand Down
17 changes: 1 addition & 16 deletions lib/fullArchive.mjs
Original file line number Diff line number Diff line change
@@ -1,23 +1,8 @@
'use strict';

import when from 'when';
import ReplaceNativeSeparator from '../util/replaceNativeSeparator.mjs';
import Run from '../util/run.mjs';
import { ReplaceNativeSeparator, Run } from './utility.mjs';

/**
* Extract an archive with full paths.
*
* @param filepath {string} Path to the archive.
* @param dest {string} Destination.
* @param options {Object} An object of acceptable 7-zip switch options.
* @param override {boolean} should binary directory change?
*
* @resolve {array} Arguments passed to the child-process.
* @progress {array} Extracted files and directories.
* @reject {Error} The error as issued by 7-Zip.
*
* @returns {Promise} Promise
*/
export default function (filepath, dest = '*', options = {}, override = false) {
return when.promise(function (resolve, reject, progress) {
/**
Expand Down
82 changes: 0 additions & 82 deletions lib/index.d.ts

This file was deleted.

125 changes: 121 additions & 4 deletions lib/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,84 @@ import _testArchive from './testArchive.mjs';
import _updateArchive from './updateArchive.mjs';
import createSfx from './createSfx.mjs';

class SevenZip {
constructor() { }
}
function SevenZip() { };

export default SevenZip;
/**
* Create/add content to an archive.
*
* @param filepath {string} Path to the archive.
* @param files {string|array} Files to add.
* @param options {Object} An object of acceptable 7-zip switch options.
* @param override {boolean} should binary directory change?
*
* @resolve {array} Arguments passed to the child-process.
* @progress {array} Listed files and directories.
* @reject {Error} The error as issued by 7-Zip.
*
* @returns {Promise} Promise
*/
export const createArchive = SevenZip.createArchive = _createArchive;

/**
* Delete content from an archive.
*
* @param filepath {string} Path to the archive.
* @param files {string|array} Files to remove.
* @param options {Object} An object of acceptable 7-zip switch options.
* @param override {boolean} should binary directory change?
*
* @resolve {array} Arguments passed to the child-process.
* @reject {Error} The error as issued by 7-Zip.
*
* @returns {Promise} Promise
*/
export const deleteArchive = SevenZip.deleteArchive = _deleteArchive;

/**
* Extract an archive.
*
* @param {string} archive Path to the archive.
* @param {string} dest Destination.
* @param options {Object} An object of acceptable 7-zip switch options.
* @param override {boolean} should binary directory change?
*
* @resolve {array} Arguments passed to the child-process.
* @progress {array} Extracted files and directories.
* @reject {Error} The error as issued by 7-Zip.
*
* @returns {Promise} Promise
*/
export const extractArchive = SevenZip.extractArchive = _extractArchive;

/**
* Extract an archive with full paths.
*
* @param filepath {string} Path to the archive.
* @param dest {string} Destination.
* @param options {Object} An object of acceptable 7-zip switch options.
* @param override {boolean} should binary directory change?
*
* @resolve {array} Arguments passed to the child-process.
* @progress {array} Extracted files and directories.
* @reject {Error} The error as issued by 7-Zip.
*
* @returns {Promise} Promise
*/
export const fullArchive = SevenZip.fullArchive = _fullArchive;

/**
* List contents of archive.
*
* @param filepath {string} Path to the archive.
* @param options {Object} An object of acceptable 7-zip switch options.
* @param override {boolean} should binary directory change?
*
* @progress {array} Listed files and directories.
* @resolve {Object} Tech spec about the archive.
* @reject {Error} The error as issued by 7-Zip.
*
* @returns {Promise} Promise
*/
export const listArchive = SevenZip.listArchive = _listArchive;

/**
Expand All @@ -38,8 +107,52 @@ export const listArchive = SevenZip.listArchive = _listArchive;
* @returns {Promise} Promise
*/
export const onlyArchive = SevenZip.onlyArchive = _onlyArchive;

/**
* Renames files in archive.
*
* @param filepath {string} Path to the archive.
* @param files {string} Files pairs to rename in archive.
* @param options {Object} An object of acceptable 7-zip switch options.
* @param override {boolean} should binary directory change?
*
* @resolve {array} Arguments passed to the child-process.
* @progress {array} Listed files and directories.
* @reject {Error} The error as issued by 7-Zip.
*
* @returns {Promise} Promise
*/
export const renameArchive = SevenZip.renameArchive = _renameArchive;

/**
* Test integrity of archive.
*
* @param filepath {string} Path to the archive.
* @param options {Object} An object of acceptable 7-zip switch options.
* @param override {boolean} should binary directory change?
*
* @resolve {array} Arguments passed to the child-process.
* @progress {array} Extracted files and directories.
* @reject {Error} The error as issued by 7-Zip.
*
* @returns {Promise} Promise
*/
export const testArchive = SevenZip.testArchive = _testArchive;

/**
* Update content to an archive.
*
* @param filepath {string} Path to the archive.
* @param files {string} Files to update.
* @param options {Object} An object of acceptable 7-zip switch options.
* @param override {boolean} should binary directory change?
*
* @resolve {array} Arguments passed to the child-process.
* @progress {array} Listed files and directories.
* @reject {Error} The error as issued by 7-Zip.
*
* @returns {Promise} Promise
*/
export const updateArchive = SevenZip.updateArchive = _updateArchive;

export const createSfxWindows = SevenZip.windowsSfx = function (name, files, destination, options, type) {
Expand All @@ -53,3 +166,7 @@ export const createSfxLinux = SevenZip.linuxSfx = function (name, files, destina
export const createSfxMac = SevenZip.macSfx = function (name, files, destination, options) {
return createSfx(name, files, destination, options, 'console', 'darwin', '.pkg');
};

export default SevenZip;

export const Zip = SevenZip;
16 changes: 1 addition & 15 deletions lib/listArchive.mjs
Original file line number Diff line number Diff line change
@@ -1,22 +1,8 @@
'use strict';

import when from 'when';
import ReplaceNativeSeparator from '../util/replaceNativeSeparator.mjs';
import Run from '../util/run.mjs';
import { ReplaceNativeSeparator, Run } from './utility.mjs';

/**
* List contents of archive.
*
* @param filepath {string} Path to the archive.
* @param options {Object} An object of acceptable 7-zip switch options.
* @param override {boolean} should binary directory change?
*
* @progress {array} Listed files and directories.
* @resolve {Object} Tech spec about the archive.
* @reject {Error} The error as issued by 7-Zip.
*
* @returns {Promise} Promise
*/
export default function (filepath, options, override = false) {
return when.promise(function (resolve, reject, progress) {
let spec = {};
Expand Down
3 changes: 1 addition & 2 deletions lib/onlyArchive.mjs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
'use strict';

import when from 'when';
import ReplaceNativeSeparator from '../util/replaceNativeSeparator.mjs';
import Run from '../util/run.mjs';
import { ReplaceNativeSeparator, Run } from './utility.mjs';

/**
* Extract only selected files from archive.
Expand Down
Loading

0 comments on commit d319fd0

Please sign in to comment.