UNPKG

hdckit

Version:

A pure Node.js client for the OpenHarmony Device Connector

38 lines (37 loc) 1.28 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.FileSendCommand = exports.FileRecvCommand = void 0; const ExecCommand_1 = __importDefault(require("../ExecCommand")); const path_1 = __importDefault(require("path")); const contain_1 = __importDefault(require("licia/contain")); class FileRecvCommand extends ExecCommand_1.default { async execute(remote, local) { const { stdout } = await this.run([ 'file', 'recv', remote, path_1.default.resolve(local), ]); if (!(0, contain_1.default)(stdout, 'finish')) { throw new Error('Recv file failed'); } } } exports.FileRecvCommand = FileRecvCommand; class FileSendCommand extends ExecCommand_1.default { async execute(local, remote) { const { stdout } = await this.run([ 'file', 'send', path_1.default.resolve(local), remote, ]); if (!(0, contain_1.default)(stdout, 'finish')) { throw new Error('Send file failed'); } } } exports.FileSendCommand = FileSendCommand;