testcafe-browser-tools
Advanced tools
Comparing version 1.4.1-git.201708221145 to 1.4.1-git.201708221215
@@ -9,5 +9,5 @@ 'use strict'; | ||
var _fs = require('fs'); | ||
var _gracefulFs = require('graceful-fs'); | ||
var _fs2 = _interopRequireDefault(_fs); | ||
var _gracefulFs2 = _interopRequireDefault(_gracefulFs); | ||
@@ -24,5 +24,14 @@ var _path = require('path'); | ||
var stat = _promisify2.default(_fs2.default.stat); | ||
var _delay = require('./delay'); | ||
var _delay2 = _interopRequireDefault(_delay); | ||
var stat = _promisify2.default(_gracefulFs2.default.stat); | ||
var open = _promisify2.default(_gracefulFs2.default.open); | ||
var close = _promisify2.default(_gracefulFs2.default.close); | ||
var mkdir = _promisify2.default(_mkdirp2.default); | ||
var MAX_RETRY_COUNT = 10; | ||
var RETRY_DELAY = 100; | ||
function createDirectory(directoryPath) { | ||
@@ -51,2 +60,103 @@ return _regeneratorRuntime.async(function createDirectory$(context$1$0) { | ||
function openFile(fileName) { | ||
var fd; | ||
return _regeneratorRuntime.async(function openFile$(context$1$0) { | ||
while (1) switch (context$1$0.prev = context$1$0.next) { | ||
case 0: | ||
context$1$0.prev = 0; | ||
context$1$0.next = 3; | ||
return _regeneratorRuntime.awrap(open(fileName, 'a')); | ||
case 3: | ||
fd = context$1$0.sent; | ||
context$1$0.next = 6; | ||
return _regeneratorRuntime.awrap(close(fd)); | ||
case 6: | ||
return context$1$0.abrupt('return', true); | ||
case 9: | ||
context$1$0.prev = 9; | ||
context$1$0.t0 = context$1$0['catch'](0); | ||
return context$1$0.abrupt('return', false); | ||
case 12: | ||
case 'end': | ||
return context$1$0.stop(); | ||
} | ||
}, null, this, [[0, 9]]); | ||
} | ||
function ensureFile(fileName) { | ||
var directoryPath, fileEnsured, i; | ||
return _regeneratorRuntime.async(function ensureFile$(context$1$0) { | ||
while (1) switch (context$1$0.prev = context$1$0.next) { | ||
case 0: | ||
directoryPath = _path.dirname(fileName); | ||
context$1$0.next = 3; | ||
return _regeneratorRuntime.awrap(createDirectory(directoryPath)); | ||
case 3: | ||
context$1$0.t0 = context$1$0.sent; | ||
if (!context$1$0.t0) { | ||
context$1$0.next = 8; | ||
break; | ||
} | ||
context$1$0.next = 7; | ||
return _regeneratorRuntime.awrap(openFile(fileName)); | ||
case 7: | ||
context$1$0.t0 = context$1$0.sent; | ||
case 8: | ||
fileEnsured = context$1$0.t0; | ||
i = 0; | ||
case 10: | ||
if (!(i < MAX_RETRY_COUNT && !fileEnsured)) { | ||
context$1$0.next = 24; | ||
break; | ||
} | ||
context$1$0.next = 13; | ||
return _regeneratorRuntime.awrap(_delay2.default(RETRY_DELAY)); | ||
case 13: | ||
context$1$0.next = 15; | ||
return _regeneratorRuntime.awrap(createDirectory(directoryPath)); | ||
case 15: | ||
context$1$0.t1 = context$1$0.sent; | ||
if (!context$1$0.t1) { | ||
context$1$0.next = 20; | ||
break; | ||
} | ||
context$1$0.next = 19; | ||
return _regeneratorRuntime.awrap(openFile(fileName)); | ||
case 19: | ||
context$1$0.t1 = context$1$0.sent; | ||
case 20: | ||
fileEnsured = context$1$0.t1; | ||
case 21: | ||
i++; | ||
context$1$0.next = 10; | ||
break; | ||
case 24: | ||
return context$1$0.abrupt('return', fileEnsured); | ||
case 25: | ||
case 'end': | ||
return context$1$0.stop(); | ||
} | ||
}, null, this); | ||
} | ||
exports.default = function callee$0$0(fileName) { | ||
@@ -76,3 +186,3 @@ var directoryPath, stats; | ||
context$1$0.next = 13; | ||
return _regeneratorRuntime.awrap(createDirectory(directoryPath)); | ||
return _regeneratorRuntime.awrap(ensureFile(fileName)); | ||
@@ -79,0 +189,0 @@ case 13: |
@@ -7,5 +7,5 @@ 'use strict'; | ||
var _fs = require('fs'); | ||
var _gracefulFs = require('graceful-fs'); | ||
var _fs2 = _interopRequireDefault(_fs); | ||
var _gracefulFs2 = _interopRequireDefault(_gracefulFs); | ||
@@ -18,3 +18,3 @@ var _pinkie = require('pinkie'); | ||
return new _pinkie2.default(function (resolve) { | ||
return _fs2.default.exists(filePath, resolve); | ||
return _gracefulFs2.default.exists(filePath, resolve); | ||
}); | ||
@@ -21,0 +21,0 @@ }; |
{ | ||
"name": "testcafe-browser-tools", | ||
"version": "1.4.1-git.201708221145", | ||
"version": "1.4.1-git.201708221215", | ||
"description": "An utility library for performing platform-dependent actions on browsers.", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/DevExpress/testcafe-browser-tools", |
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
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
1597365
1639
1