-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
copy missing progress fn (this is temporary)
- Loading branch information
1 parent
f6edccf
commit 4226459
Showing
4 changed files
with
127 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
91 changes: 91 additions & 0 deletions
91
...-wordpress/src/steps/source-nodes/create-nodes/create-remote-file-node/create-progress.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
exports.__esModule = true | ||
exports.getRemoteFileExtension = getRemoteFileExtension | ||
exports.getRemoteFileName = getRemoteFileName | ||
exports.createProgress = createProgress | ||
exports.createFilePath = createFilePath | ||
|
||
const path = require(`path`) | ||
|
||
const Url = require(`url`) | ||
|
||
const ProgressBar = require(`progress`) | ||
/** | ||
* getParsedPath | ||
* -- | ||
* Parses remote url to a path object | ||
* | ||
* | ||
* @param {String} url | ||
* @return {Object} path | ||
*/ | ||
|
||
function getParsedPath(url) { | ||
return path.parse(Url.parse(url).pathname) | ||
} | ||
/** | ||
* getRemoteFileExtension | ||
* -- | ||
* Parses remote url to retrieve remote file extension | ||
* | ||
* | ||
* @param {String} url | ||
* @return {String} extension | ||
*/ | ||
|
||
function getRemoteFileExtension(url) { | ||
return getParsedPath(url).ext | ||
} | ||
/** | ||
* getRemoteFileName | ||
* -- | ||
* Parses remote url to retrieve remote file name | ||
* | ||
* | ||
* @param {String} url | ||
* @return {String} filename | ||
*/ | ||
|
||
function getRemoteFileName(url) { | ||
return getParsedPath(url).name | ||
} // TODO remove in V3 | ||
|
||
function createProgress(message, reporter) { | ||
if (reporter && reporter.createProgress) { | ||
return reporter.createProgress(message) | ||
} | ||
|
||
const bar = new ProgressBar( | ||
` [:bar] :current/:total :elapsed s :percent ${message}`, | ||
{ | ||
total: 0, | ||
width: 30, | ||
clear: true, | ||
} | ||
) | ||
return { | ||
start() {}, | ||
|
||
tick() { | ||
bar.tick() | ||
}, | ||
|
||
done() {}, | ||
|
||
set total(value) { | ||
bar.total = value | ||
}, | ||
} | ||
} | ||
/** | ||
* createFilePath | ||
* -- | ||
* | ||
* @param {String} directory | ||
* @param {String} filename | ||
* @param {String} ext | ||
* @return {String} | ||
*/ | ||
|
||
function createFilePath(directory, filename, ext) { | ||
return path.join(directory, `${filename}${ext}`) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters