Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

dmg-utils

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dmg-utils - npm Package Compare versions

Comparing version 0.0.1 to 0.1.0

dist/index.d.ts

23

.eslintrc.js

@@ -1,22 +0,1 @@

module.exports = {
env: {
commonjs: true,
es2021: true,
node: true
},
extends: [
'standard',
'plugin:prettier/recommended',
'prettier/@typescript-eslint',
'prettier/standard'
],
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 12
},
plugins: ['@typescript-eslint', 'prettier'],
ignorePatterns: ['dist/**/*'],
rules: {
'prettier/prettier': 'error'
}
}
module.exports = require('ts-standardx/.eslintrc.js')

@@ -7,3 +7,3 @@ import { promisify } from 'util';

const execAsync = promisify(exec);
const command = (mount) => (path) => `hdiutil ${mount ? "mount -nobrowse" : "unmount"} "${path}"`;
const generateCommand = ({ mount }) => (path) => `hdiutil ${mount ? 'mount -nobrowse' : 'unmount'} "${path}"`;

@@ -36,12 +36,12 @@ /*! *****************************************************************************

const mount = (dmgPath, callback) => __awaiter(void 0, void 0, void 0, function* () {
const { stdout, stderr } = yield execAsync(command(true)(dmgPath));
if (stderr) {
const { stdout, stderr } = yield execAsync(generateCommand({ mount: true })(dmgPath));
if (stderr !== undefined) {
throw new Error(stderr);
}
const match = stdout.match(VOLUME_REGEX);
if (!match) {
if (match === null) {
throw new Error(`Could not extract path out of mount result: ${stdout}`);
}
if (callback) {
return callback(match[0]);
if (callback !== undefined) {
callback(match[0]);
}

@@ -55,7 +55,7 @@ return match[0];

}
const { stderr } = yield execAsync(command(false)(volumePath));
if (stderr) {
const { stderr } = yield execAsync(generateCommand({ mount: false })(volumePath));
if (stderr !== undefined) {
throw new Error(stderr);
}
if (callback) {
if (callback !== undefined) {
callback();

@@ -71,2 +71,2 @@ }

export { command, extract, mount, unmount };
export { extract, generateCommand, mount, unmount };

@@ -11,3 +11,3 @@ 'use strict';

const execAsync = util.promisify(child_process.exec);
const command = (mount) => (path) => `hdiutil ${mount ? "mount -nobrowse" : "unmount"} "${path}"`;
const generateCommand = ({ mount }) => (path) => `hdiutil ${mount ? 'mount -nobrowse' : 'unmount'} "${path}"`;

@@ -40,12 +40,12 @@ /*! *****************************************************************************

const mount = (dmgPath, callback) => __awaiter(void 0, void 0, void 0, function* () {
const { stdout, stderr } = yield execAsync(command(true)(dmgPath));
if (stderr) {
const { stdout, stderr } = yield execAsync(generateCommand({ mount: true })(dmgPath));
if (stderr !== undefined) {
throw new Error(stderr);
}
const match = stdout.match(VOLUME_REGEX);
if (!match) {
if (match === null) {
throw new Error(`Could not extract path out of mount result: ${stdout}`);
}
if (callback) {
return callback(match[0]);
if (callback !== undefined) {
callback(match[0]);
}

@@ -59,7 +59,7 @@ return match[0];

}
const { stderr } = yield execAsync(command(false)(volumePath));
if (stderr) {
const { stderr } = yield execAsync(generateCommand({ mount: false })(volumePath));
if (stderr !== undefined) {
throw new Error(stderr);
}
if (callback) {
if (callback !== undefined) {
callback();

@@ -75,5 +75,5 @@ }

exports.command = command;
exports.extract = extract;
exports.generateCommand = generateCommand;
exports.mount = mount;
exports.unmount = unmount;
{
"name": "dmg-utils",
"version": "0.0.1",
"version": "0.1.0",
"description": "Util lib for DMG files.",
"main": "dist/index.js",
"module": "dist/index.es.js",
"types": "dist/types/index.d.ts",
"types": "dist/index.d.ts",
"scripts": {
"build": "rimraf dist && rollup -c && tsc -d --emitDeclarationOnly --declarationDir dist/types",
"lint": "eslint \"**/*.{js,ts}\"",
"format": "prettier --write .",
"test": "yarn lint && yarn build"
"clean": "rimraf .cache dist",
"dts": "tsc -d --emitDeclarationOnly --declarationDir .cache",
"bundle": "rollup -c",
"build": "npm run clean && npm run dts && npm run bundle",
"lint": "ts-standardx",
"lint:fix": "ts-standardx --fix",
"test": "npm run lint && npm run build"
},

@@ -28,25 +31,15 @@ "repository": {

"dependencies": {
"fs-extra": "9.0.1"
"fs-extra": "9.1.0"
},
"devDependencies": {
"@rollup/plugin-typescript": "6.1.0",
"@types/fs-extra": "9.0.2",
"@types/node": "14.14.5",
"@typescript-eslint/eslint-plugin": "4.6.0",
"@typescript-eslint/parser": "4.6.0",
"eslint": "7.12.1",
"eslint-config-prettier": "6.15.0",
"eslint-config-standard": "15.0.1",
"eslint-plugin-import": "2.22.1",
"eslint-plugin-node": "11.1.0",
"eslint-plugin-prettier": "3.1.4",
"eslint-plugin-promise": "4.2.1",
"eslint-plugin-standard": "4.0.2",
"prettier": "2.1.2",
"prettier-config-standard": "1.0.1",
"@rollup/plugin-typescript": "8.1.1",
"@types/fs-extra": "9.0.6",
"@types/node": "14.14.25",
"rimraf": "3.0.2",
"rollup": "2.32.1",
"tslib": "2.0.3",
"typescript": "4.1.0-beta"
"rollup": "2.38.5",
"rollup-plugin-dts": "2.0.1",
"ts-standardx": "0.6.0",
"tslib": "2.1.0",
"typescript": "4.2.0-beta"
}
}

@@ -6,3 +6,3 @@ # dmg-utils [WIP]

[![npm](https://img.shields.io/npm/v/dmg-utils.svg?style=flat-square)](https://www.npmjs.com/package/dmg-utils)
[![David](https://img.shields.io/david/exuanbo/dmg-utils.svg?style=flat-square)](https://david-dm.org/exuanbo/dmg-utils)
[![libera manifesto](https://img.shields.io/badge/libera-manifesto-lightgrey.svg)](https://liberamanifesto.com)

@@ -19,31 +19,12 @@ By now it only works on macOS.

### command
```ts
export declare const command: <
T extends string,
K extends `hdiutil mount -nobrowse "${T}"` | `hdiutil unmount "${T}"`
>(mount: boolean) => (path: T) => K
```
```js
import { command } from 'dmg-utils'
command(true)('./App.dmg')
//=> 'hdiutil mount -nobrowse "./App.dmg"'
command(false)('/Volumes/App')
//=> 'hdiutil unmount "/Volumes/App"'
```
### mount
```ts
export declare const mount: <T = string>(
declare const mount: (
dmgPath: string,
callback?: ((volumePath: string) => T) | undefined
) => Promise<string | T>
callback?: ((volumePath: string) => void) | undefined
) => Promise<string>
```
Returns mounted volume path if no callback function provided.
Returns mounted volume path.

@@ -53,5 +34,5 @@ ### unmount

```ts
export declare const unmount: (
declare const unmount: (
volumePath: string,
callback?: Function | undefined
callback?: (() => void) | undefined
) => Promise<void>

@@ -63,6 +44,3 @@ ```

```ts
export declare const extract: (
dmgPath: string,
destPath: string
) => Promise<void>
declare const extract: (dmgPath: string, destPath: string) => Promise<void>
```

@@ -72,4 +50,26 @@

### generateCommand
```ts
declare type Action = 'mount -nobrowse' | 'unmount'
declare type Command = `hdiutil ${Action} "${string}"`
declare const generateCommand: ({
mount
}: {
mount: boolean
}) => (path: string) => Command
```
```js
import { generateCommand } from 'dmg-utils'
generateCommand({ mount: true })('./App.dmg')
// => 'hdiutil mount -nobrowse "./App.dmg"'
generateCommand({ mount: false })('/Volumes/App')
// => 'hdiutil unmount "/Volumes/App"'
```
## License
[MIT License](https://github.com/exuanbo/dmg-utils/blob/main/LICENSE) © 2020 [Exuanbo](https://github.com/exuanbo)
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc