Comparing version 0.7.2 to 0.7.3
@@ -35,5 +35,5 @@ 'use strict'; | ||
constructor(dat, program) { | ||
constructor(dat, options) { | ||
this.dat = dat; | ||
this.program = program; | ||
this.options = options; | ||
this.files = 0; | ||
@@ -49,3 +49,3 @@ this.totalSize = 0; | ||
if (_this.program.dryRun) { | ||
if (_this.options.dryRun) { | ||
_this.printTotal(); | ||
@@ -95,3 +95,3 @@ process.exit(0); | ||
if (stats.isFile()) { | ||
_this3.countPath(path, stats, _this3.program.dryRun); | ||
_this3.countPath(path, stats); | ||
return; | ||
@@ -113,3 +113,3 @@ } | ||
return _asyncToGenerator(function* () { | ||
if (!_this4.program.recursive) { | ||
if (!_this4.options.recursive) { | ||
_logger2.default.warn(`${path}: Is a directory (not copied).`); | ||
@@ -120,3 +120,3 @@ return; | ||
if (path[path.length - 1] !== '/') { | ||
_this4.countPath(path, stats, _this4.program.dryRun); | ||
_this4.countPath(path, stats); | ||
} | ||
@@ -165,3 +165,3 @@ | ||
return _asyncToGenerator(function* () { | ||
if (!_this7.program.recursive) { | ||
if (!_this7.options.recursive) { | ||
return; | ||
@@ -197,3 +197,3 @@ } | ||
download(listOnly = false) { | ||
download() { | ||
var _this8 = this; | ||
@@ -215,8 +215,5 @@ | ||
for (const path of paths) { | ||
yield _this8.downloadPath(path, listOnly); | ||
yield _this8.downloadPath(path); | ||
} | ||
if (_this8.program.dryRun || !listOnly && _this8.files > 30 || _this8.files === 0) { | ||
_this8.printTotal(); | ||
} | ||
resolve(); | ||
@@ -237,3 +234,3 @@ } else { | ||
downloadPath(path, listOnly) { | ||
downloadPath(path) { | ||
var _this9 = this; | ||
@@ -245,5 +242,5 @@ | ||
if (stats.isDirectory()) { | ||
yield _this9.downloadDir(path, stats, listOnly); | ||
yield _this9.downloadDir(path, stats); | ||
} else { | ||
yield _this9.downloadFile(path, stats, listOnly); | ||
yield _this9.downloadFile(path, stats); | ||
} | ||
@@ -253,3 +250,3 @@ })(); | ||
downloadFile(path, stats, listOnly) { | ||
downloadFile(path, stats) { | ||
var _this10 = this; | ||
@@ -270,5 +267,5 @@ | ||
_this10.countPath(path, stats, listOnly); | ||
_this10.countPath(path, stats); | ||
if (listOnly) { | ||
if (_this10.options.dryRun) { | ||
return; | ||
@@ -285,7 +282,7 @@ } | ||
downloadDir(path, stats, listOnly) { | ||
downloadDir(path, stats) { | ||
var _this11 = this; | ||
return _asyncToGenerator(function* () { | ||
if (!listOnly) { | ||
if (!_this11.options.dryRun) { | ||
// lstat will throw an error if a path does not exist, so rely on that to | ||
@@ -305,3 +302,3 @@ // know that the dir does not already exist. If the path exists and is not | ||
_this11.countPath(path, stats, listOnly); | ||
_this11.countPath(path, stats); | ||
@@ -311,3 +308,3 @@ const dirPaths = yield _this11.readdir(path); | ||
for (const dirPath of dirPaths) { | ||
yield _this11.downloadPath(_path2.default.join(path, dirPath), listOnly); | ||
yield _this11.downloadPath(_path2.default.join(path, dirPath)); | ||
} | ||
@@ -317,3 +314,3 @@ })(); | ||
countPath(path, stats, listPath) { | ||
countPath(path, stats) { | ||
if (path === '.') { | ||
@@ -326,3 +323,3 @@ return; | ||
if (!listPath) { | ||
if (!this.options.dryRun) { | ||
return; | ||
@@ -342,7 +339,2 @@ } | ||
resetCounts() { | ||
this.files = 0; | ||
this.totalSize = 0; | ||
} | ||
downloadPrompt() { | ||
@@ -349,0 +341,0 @@ var _this12 = this; |
@@ -7,2 +7,4 @@ 'use strict'; | ||
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; | ||
var _dat = require('./lib/dat'); | ||
@@ -21,17 +23,16 @@ | ||
exports.default = (() => { | ||
var _ref = _asyncToGenerator(function* (key, program) { | ||
var _ref = _asyncToGenerator(function* (key, options) { | ||
const dat = yield (0, _dat2.default)({ key, sparse: true }); | ||
const datCp = new _datCp2.default(dat, program); | ||
if (!options.skipPrompt) { | ||
const datCpDryRun = new _datCp2.default(dat, _extends({}, options, { dryRun: true })); | ||
if (!program.skipPrompt) { | ||
yield datCp.download(true); | ||
} | ||
yield datCpDryRun.download(); | ||
if (program.dryRun || !program.skipPrompt && datCp.files === 0) { | ||
process.exit(); | ||
} | ||
if (options.dryRun || datCpDryRun.files === 0) { | ||
datCpDryRun.printTotal(); | ||
process.exit(); | ||
} | ||
if (!program.skipPrompt) { | ||
const proceed = yield datCp.downloadPrompt(); | ||
const proceed = yield datCpDryRun.downloadPrompt(); | ||
@@ -43,5 +44,10 @@ if (!proceed) { | ||
datCp.resetCounts(); | ||
yield datCp.download(); | ||
const datCpDownload = new _datCp2.default(dat, _extends({}, options)); | ||
yield datCpDownload.download(); | ||
if (options.skipPrompt || datCpDownload.files > 30) { | ||
datCpDownload.printTotal(); | ||
} | ||
process.exit(); | ||
@@ -48,0 +54,0 @@ }); |
@@ -32,6 +32,6 @@ 'use strict'; | ||
exports.default = (() => { | ||
var _ref = _asyncToGenerator(function* (paths, program) { | ||
var _ref = _asyncToGenerator(function* (paths, options) { | ||
const dat = yield (0, _dat2.default)(); | ||
const datCp = new _datCp2.default(dat, program); | ||
const datCp = new _datCp2.default(dat, options); | ||
yield datCp.upload(paths); | ||
@@ -38,0 +38,0 @@ |
{ | ||
"name": "dat-cp", | ||
"version": "0.7.2", | ||
"version": "0.7.3", | ||
"description": "Dat Copy - remote file copy, powered by the dat protocol", | ||
@@ -5,0 +5,0 @@ "engines": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
39494
874