Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch from filenamify-url to filenamify #395

Merged
merged 2 commits into from
Jun 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 15 additions & 4 deletions lib/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const findCacheDir = require('find-cache-dir');
const Git = require('./git');
const filenamify = require('filenamify-url');
const filenamify = require('filenamify');
const copy = require('./util').copy;
const getUser = require('./util').getUser;
const fs = require('fs-extra');
Expand All @@ -10,9 +10,20 @@ const util = require('util');

const log = util.debuglog('gh-pages');

function getCacheDir() {
return findCacheDir({name: 'gh-pages'});
/**
* Get the cache directory.
* @param {string} [optPath] Optional path.
* @returns {string} The full path to the cache directory.
*/
function getCacheDir(optPath) {
const dir = findCacheDir({name: 'gh-pages'});
if (!optPath) {
return dir;
}

return path.join(dir, filenamify(optPath));
}
exports.getCacheDir = getCacheDir;

function getRepo(options) {
if (options.repo) {
Expand Down Expand Up @@ -111,7 +122,7 @@ exports.publish = function publish(basePath, config, callback) {
getRepo(options)
.then(repo => {
repoUrl = repo;
const clone = path.join(getCacheDir(), filenamify(repo));
const clone = getCacheDir(repo);
log('Cloning %s into %s', repo, clone);
return Git.clone(repo, clone, options.branch, options);
})
Expand Down
198 changes: 21 additions & 177 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"async": "^2.6.1",
"commander": "^2.18.0",
"email-addresses": "^3.0.1",
"filenamify-url": "^1.0.0",
"filenamify": "^4.3.0",
"find-cache-dir": "^3.3.1",
"fs-extra": "^8.1.0",
"globby": "^6.1.0"
Expand Down