Socket
Socket
Sign inDemoInstall

gh-pages

Package Overview
Dependencies
Maintainers
2
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gh-pages - npm Package Compare versions

Comparing version 2.2.0 to 3.0.0

28

bin/gh-pages.js

@@ -66,3 +66,3 @@ #!/usr/bin/env node

'(ignored if used together with --add).',
ghpages.defaults.only
ghpages.defaults.remove
)

@@ -74,2 +74,6 @@ .option('-n, --no-push', 'Commit only (with no push)')

)
.option(
'--before-add <file>',
'Execute the function exported by <file> before "git add"'
)
.parse(args);

@@ -88,3 +92,20 @@

}
let beforeAdd;
if (program.beforeAdd) {
const m = require(require.resolve(program.beforeAdd, {
paths: [process.cwd()]
}));
if (typeof m === 'function') {
beforeAdd = m;
} else if (typeof m === 'object' && typeof m.default === 'function') {
beforeAdd = m.default;
} else {
throw new Error(
`Could not find function to execute before adding files in ` +
`"${program.beforeAdd}".\n `
);
}
}
const config = {

@@ -102,7 +123,8 @@ repo: program.repo,

add: !!program.add,
only: program.remove,
remove: program.remove,
remote: program.remote,
push: !!program.push,
history: !!program.history,
user: user
user: user,
beforeAdd: beforeAdd
};

@@ -109,0 +131,0 @@

@@ -0,1 +1,17 @@

## v3.0.0
Breaking changes:
None really. But tests are no longer run on Node < 10. Development dependencies were updated to address security warnings, and this meant tests could no longer be run on Node 6 or 8. If you still use these Node versions, you may still be able to use this library, but be warned that tests are no longer run on these versions.
All changes:
* [#357](https://github.com/tschaub/gh-pages/pull/357) - Dev dependency updates ([@tschaub](https://github.com/tschaub))
* [#333](https://github.com/tschaub/gh-pages/pull/333) - Update readme with command line options ([@Victoire44](https://github.com/Victoire44))
* [#356](https://github.com/tschaub/gh-pages/pull/356) - Test as a GitHub action ([@tschaub](https://github.com/tschaub))
* [#355](https://github.com/tschaub/gh-pages/pull/355) - feat(beforeAdd): allow custom script before git add ([@Xiphe](https://github.com/Xiphe))
* [#336](https://github.com/tschaub/gh-pages/pull/336) - Fix remove not working properly ([@sunghwan2789](https://github.com/sunghwan2789))
* [#328](https://github.com/tschaub/gh-pages/pull/328) - Update .travis.yml ([@XhmikosR](https://github.com/XhmikosR))
* [#327](https://github.com/tschaub/gh-pages/pull/327) - Fix typo ([@d-tsuji](https://github.com/d-tsuji))
## v2.2.0

@@ -2,0 +18,0 @@

18

lib/git.js

@@ -69,3 +69,3 @@ const cp = require('child_process');

Git.prototype.exec = function() {
return spawn(this.cmd, [].slice.call(arguments), this.cwd).then(output => {
return spawn(this.cmd, [...arguments], this.cwd).then(output => {
this.output = output;

@@ -140,7 +140,10 @@ return this;

* Remove all unversioned files.
* @param {string} files Files argument.
* @param {string|string[]} files Files argument.
* @return {Promise} A promise.
*/
Git.prototype.rm = function(files) {
return this.exec('rm', '--ignore-unmatch', '-r', '-f', files);
if (!Array.isArray(files)) {
files = [files];
}
return this.exec('rm', '--ignore-unmatch', '-r', '-f', ...files);
};

@@ -150,7 +153,10 @@

* Add files.
* @param {string} files Files argument.
* @param {string|string[]} files Files argument.
* @return {Promise} A promise.
*/
Git.prototype.add = function(files) {
return this.exec('add', files);
if (!Array.isArray(files)) {
files = [files];
}
return this.exec('add', ...files);
};

@@ -259,3 +265,3 @@

.catch(err => {
// try again without banch or depth options
// try again without branch or depth options
return spawn(options.git, [

@@ -262,0 +268,0 @@ 'clone',

@@ -34,3 +34,3 @@ const Git = require('./git');

src: '**/*',
only: '.',
remove: '.',
push: true,

@@ -56,2 +56,7 @@ history: true,

// For backward compatibility before fixing #334
if (options.only) {
options.remove = options.only;
}
if (!callback) {

@@ -99,6 +104,2 @@ callback = function(err) {

const only = globby.sync(options.only, {cwd: basePath}).map(file => {
return path.join(options.dest, file);
});
let repoUrl;

@@ -157,5 +158,14 @@ let userPromise;

.then(git => {
if (!options.add) {
log('Removing files');
return git.rm(only.join(' '));
if (options.add) {
return git;
}
log('Removing files');
const files = globby
.sync(options.remove, {
cwd: path.join(git.cwd, options.dest)
})
.map(file => path.join(options.dest, file));
if (files.length > 0) {
return git.rm(files);
} else {

@@ -174,2 +184,7 @@ return git;

.then(git => {
return Promise.resolve(
options.beforeAdd && options.beforeAdd(git)
).then(() => git);
})
.then(git => {
log('Adding all');

@@ -176,0 +191,0 @@ return git.add('.');

{
"name": "gh-pages",
"version": "2.2.0",
"version": "3.0.0",
"description": "Publish to a gh-pages branch on GitHub (or any other branch on any other remote)",

@@ -29,4 +29,8 @@ "keywords": [

},
"files": [
"lib",
"bin"
],
"engines": {
"node": ">=6"
"node": ">=10"
},

@@ -44,7 +48,7 @@ "dependencies": {

"dir-compare": "^1.8.0",
"eslint": "^5.16.0",
"eslint": "^7.1.0",
"eslint-config-tschaub": "^13.1.0",
"mocha": "^6.2.2",
"sinon": "^8.0.4",
"tmp": "^0.1.0"
"tmp": "^0.2.1"
},

@@ -51,0 +55,0 @@ "bin": {

@@ -80,2 +80,3 @@

* default: `'gh-pages'`
* `-b | --branch <branch name>`

@@ -152,2 +153,3 @@ The name of the branch you'll be pushing to. The default uses GitHub's `gh-pages` branch, but this can be configured to push to any branch on any remote.

* default: url for the origin remote of the current dir (assumes a git repository)
* `-r | --repo <repo url>`

@@ -294,2 +296,31 @@ By default, `gh-pages` assumes that the current working directory is a git repository, and that you want to push changes to the `origin` remote.

#### <a id="optionsbeforeadd">options.beforeAdd</a>
* type: `function`
* default: `null`
Custom callback that is executed right before `git add`.
The CLI expects a file exporting the beforeAdd function
```bash
gh-pages --before-add ./cleanup.js
```
Example use of the `beforeAdd` option:
```js
/**
* beforeAdd makes most sense when `add` option is active
* Assuming we want to keep everything on the gh-pages branch
* but remove just `some-outdated-file.txt`
*/
ghpages.publish('dist', {
add: true,
async beforeAdd(git) {
return git.rm('./some-outdated-file.txt');
}
}, callback);
```
#### <a id="optionsgit">options.git</a>

@@ -342,3 +373,3 @@ * type: `string`

[![Current Status](https://secure.travis-ci.org/tschaub/gh-pages.svg?branch=master)](https://travis-ci.org/tschaub/gh-pages)
![Test Status](https://github.com/tschaub/gh-pages/workflows/Test/badge.svg)

@@ -345,0 +376,0 @@ ## Tips

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc