Skip to content

Commit

Permalink
Merge pull request #587 from tschaub/dependabot/npm_and_yarn/eslint-c…
Browse files Browse the repository at this point in the history
…onfig-tschaub-15.1.0

Bump eslint-config-tschaub from 14.1.2 to 15.1.0
  • Loading branch information
tschaub authored Dec 9, 2024
2 parents b367534 + b18ebf0 commit 4be5ff0
Show file tree
Hide file tree
Showing 22 changed files with 1,649 additions and 761 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ jobs:
os:
- ubuntu-latest
node:
- 16
- 18
- 20
- 22

steps:
- name: Clone repository
Expand Down
40 changes: 21 additions & 19 deletions bin/gh-pages.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#!/usr/bin/env node

const ghpages = require('../lib/index.js');
const {Command} = require('commander');
const path = require('path');
const pkg = require('../package.json');
const {Command} = require('commander');
const addr = require('email-addresses');
const ghpages = require('../lib/index.js');
const pkg = require('../package.json');

function publish(dist, config) {
return new Promise((resolve, reject) => {
Expand All @@ -24,63 +24,63 @@ function main(args) {
.version(pkg.version)
.requiredOption(
'-d, --dist <dist>',
'Base directory for all source files'
'Base directory for all source files',
)
.option(
'-s, --src <src>',
'Pattern used to select which files to publish',
ghpages.defaults.src
ghpages.defaults.src,
)
.option(
'-b, --branch <branch>',
'Name of the branch you are pushing to',
ghpages.defaults.branch
ghpages.defaults.branch,
)
.option(
'-e, --dest <dest>',
'Target directory within the destination branch (relative to the root)',
ghpages.defaults.dest
ghpages.defaults.dest,
)
.option('-a, --add', 'Only add, and never remove existing files')
.option('-x, --silent', 'Do not output the repository url')
.option(
'-m, --message <message>',
'commit message',
ghpages.defaults.message
ghpages.defaults.message,
)
.option('-g, --tag <tag>', 'add tag to commit')
.option('--git <git>', 'Path to git executable', ghpages.defaults.git)
.option('-t, --dotfiles', 'Include dotfiles')
.option('--nojekyll', 'Add a .nojekyll file to disable Jekyll')
.option(
'--cname <CNAME>',
'Add a CNAME file with the name of your custom domain'
'Add a CNAME file with the name of your custom domain',
)
.option('-r, --repo <repo>', 'URL of the repository you are pushing to')
.option('-p, --depth <depth>', 'depth for clone', ghpages.defaults.depth)
.option(
'-o, --remote <name>',
'The name of the remote',
ghpages.defaults.remote
ghpages.defaults.remote,
)
.option(
'-u, --user <address>',
'The name and email of the user (defaults to the git config). Format is "Your Name <[email protected]>".'
'The name and email of the user (defaults to the git config). Format is "Your Name <[email protected]>".',
)
.option(
'-v, --remove <pattern>',
'Remove files that match the given pattern ' +
'(ignored if used together with --add).',
ghpages.defaults.remove
ghpages.defaults.remove,
)
.option('-n, --no-push', 'Commit only (with no push)')
.option(
'-f, --no-history',
'Push force new commit without parent history'
'Push force new commit without parent history',
)
.option(
'--before-add <file>',
'Execute the function exported by <file> before "git add"'
'Execute the function exported by <file> before "git add"',
)
.parse(args);

Expand All @@ -92,16 +92,18 @@ function main(args) {
if (!parts) {
throw new Error(
`Could not parse name and email from user option "${options.user}" ` +
'(format should be "Your Name <[email protected]>")'
'(format should be "Your Name <[email protected]>")',
);
}
user = {name: parts.name, email: parts.address};
}
let beforeAdd;
if (options.beforeAdd) {
const m = require(require.resolve(options.beforeAdd, {
paths: [process.cwd()],
}));
const m = require(
require.resolve(options.beforeAdd, {
paths: [process.cwd()],
}),
);

if (typeof m === 'function') {
beforeAdd = m;
Expand All @@ -110,7 +112,7 @@ function main(args) {
} else {
throw new Error(
`Could not find function to execute before adding files in ` +
`"${options.beforeAdd}".\n `
`"${options.beforeAdd}".\n `,
);
}
}
Expand Down
3 changes: 3 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import configs from 'eslint-config-tschaub';

export default [...configs];
10 changes: 5 additions & 5 deletions lib/git.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const cp = require('child_process');
const fs = require('fs-extra');
const path = require('path');
const util = require('util');
const fs = require('fs-extra');

/**
* @function Object() { [native code] }
Expand Down Expand Up @@ -130,7 +130,7 @@ Git.prototype.checkout = function (remote, branch) {
// unhandled error
throw error;
}
}
},
);
};

Expand Down Expand Up @@ -165,7 +165,7 @@ Git.prototype.add = function (files) {
*/
Git.prototype.commit = function (message) {
return this.exec('diff-index', '--quiet', 'HEAD').catch(() =>
this.exec('commit', '-m', message)
this.exec('commit', '-m', message),
);
};

Expand Down Expand Up @@ -206,7 +206,7 @@ Git.prototype.getRemoteUrl = function (remote) {
return repo;
} else {
throw new Error(
'Failed to get repo URL from options or current directory.'
'Failed to get repo URL from options or current directory.',
);
}
})
Expand All @@ -218,7 +218,7 @@ Git.prototype.getRemoteUrl = function (remote) {
'run in a git repository with a configured ' +
remote +
' remote ' +
'or must be configured with the "repo" option).'
'or must be configured with the "repo" option).',
);
});
};
Expand Down
57 changes: 29 additions & 28 deletions lib/index.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
const path = require('path');
const util = require('util');
const filenamify = require('filenamify');
const findCacheDir = require('find-cache-dir');
const fs = require('fs-extra');
const globby = require('globby');
const Git = require('./git.js');
const filenamify = require('filenamify');
const copy = require('./util.js').copy;
const getUser = require('./util.js').getUser;
const fs = require('fs-extra');
const globby = require('globby');
const path = require('path');
const util = require('util');

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

Expand All @@ -23,16 +23,13 @@ function getCacheDir(optPath) {

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

function getRepo(options) {
if (options.repo) {
return Promise.resolve(options.repo);
} else {
const git = new Git(process.cwd(), options.git);
return git.getRemoteUrl(options.remote);
}
}
/**
* Clean the cache directory.
*/
exports.clean = function clean() {
fs.removeSync(getCacheDir());
};

exports.defaults = {
dest: '.',
Expand All @@ -50,10 +47,21 @@ exports.defaults = {
silent: false,
};

exports.getCacheDir = getCacheDir;

function getRepo(options) {
if (options.repo) {
return Promise.resolve(options.repo);
} else {
const git = new Git(process.cwd(), options.git);
return git.getRemoteUrl(options.remote);
}
}

/**
* Push a git branch to a remote (pushes gh-pages by default).
* @param {string} basePath The base path.
* @param {object} config Publish options.
* @param {Object} config Publish options.
* @param {Function} callback Callback.
* @return {Promise} A promise.
*/
Expand Down Expand Up @@ -108,7 +116,7 @@ exports.publish = function publish(basePath, config, callback) {

if (!Array.isArray(files) || files.length === 0) {
done(
new Error('The pattern in the "src" property didn\'t match any files.')
new Error('The pattern in the "src" property didn\'t match any files.'),
);
return;
}
Expand Down Expand Up @@ -195,12 +203,12 @@ exports.publish = function publish(basePath, config, callback) {
return copy(files, basePath, path.join(git.cwd, options.dest)).then(
function () {
return git;
}
},
);
})
.then((git) => {
return Promise.resolve(
options.beforeAdd && options.beforeAdd(git)
options.beforeAdd && options.beforeAdd(git),
).then(() => git);
})
.then((git) => {
Expand Down Expand Up @@ -248,18 +256,11 @@ exports.publish = function publish(basePath, config, callback) {
(error) => {
if (options.silent) {
error = new Error(
'Unspecified error (run without silent option for detail)'
'Unspecified error (run without silent option for detail)',
);
}
done(error);
}
)
},
),
);
};

/**
* Clean the cache directory.
*/
exports.clean = function clean() {
fs.removeSync(getCacheDir());
};
Loading

0 comments on commit 4be5ff0

Please sign in to comment.