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

Drop dependency on deprecated gulp-util #120

Merged
merged 1 commit into from
Jul 13, 2018
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 15 additions & 14 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

const Transform = require('stream').Transform;

const fancyLog = require('fancy-log');
const git = require('./lib/git');
const gutil = require('gulp-util');
const PluginError = require('plugin-error');
const vinylFs = require('vinyl-fs');
const wrapPromise = require('wrap-promise');

Expand Down Expand Up @@ -43,7 +44,7 @@ module.exports = function gulpGhPages(options) {
}

if (file.isStream()) {
cb(new gutil.PluginError('gulp-gh-pages', 'Stream content is not supported'));
cb(new PluginError('gulp-gh-pages', 'Stream content is not supported'));
return;
}

Expand All @@ -52,7 +53,7 @@ module.exports = function gulpGhPages(options) {
},
flush: function publish(cb) {
if (files.length === 0) {
gutil.log(TAG, 'No files in the stream.');
fancyLog(TAG, 'No files in the stream.');
cb();
return;
}
Expand All @@ -61,18 +62,18 @@ module.exports = function gulpGhPages(options) {

git.prepareRepo(options.remoteUrl, origin, options.cacheDir || '.publish')
.then(repo => {
gutil.log(TAG, 'Cloning repo');
fancyLog(TAG, 'Cloning repo');
if (repo._localBranches.indexOf(branch) > -1) {
gutil.log(TAG, `Checkout branch \`${branch}\``);
fancyLog(TAG, `Checkout branch \`${branch}\``);
return repo.checkoutBranch(branch);
}

if (repo._remoteBranches.indexOf(`${origin}/${branch}`) > -1) {
gutil.log(TAG, `Checkout remote branch \`${branch}\``);
fancyLog(TAG, `Checkout remote branch \`${branch}\``);
return repo.checkoutBranch(branch);
}

gutil.log(TAG, `Create branch \`${branch}\` and checkout`);
fancyLog(TAG, `Create branch \`${branch}\` and checkout`);
newBranchCreated = true;
return repo.createAndCheckoutBranch(branch);
})
Expand All @@ -83,7 +84,7 @@ module.exports = function gulpGhPages(options) {
}

// updating to avoid having local cache not up to date
gutil.log(TAG, 'Updating repository');
fancyLog(TAG, 'Updating repository');
repo._repo.git('pull', err => {
if (err) {
reject(err);
Expand All @@ -102,7 +103,7 @@ module.exports = function gulpGhPages(options) {
});
}))
.then(repo => {
gutil.log(TAG, 'Copying files to repository');
fancyLog(TAG, 'Copying files to repository');

return wrapPromise((resolve, reject) => {
const destStream = vinylFs.dest(repo._repo.path)
Expand All @@ -123,16 +124,16 @@ module.exports = function gulpGhPages(options) {
.then(repo => {
const filesToBeCommitted = Object.keys(repo._staged).length;
if (filesToBeCommitted === 0) {
gutil.log(TAG, 'No files have changed.');
fancyLog(TAG, 'No files have changed.');
cb();
return;
}

gutil.log(TAG, `Adding ${filesToBeCommitted} files.`);
gutil.log(TAG, `Committing "${message}"`);
fancyLog(TAG, `Adding ${filesToBeCommitted} files.`);
fancyLog(TAG, `Committing "${message}"`);
repo.commit(message).then(newRepo => {
if (options.push === undefined || options.push) {
gutil.log(TAG, 'Pushing to remote.');
fancyLog(TAG, 'Pushing to remote.');
newRepo._repo.git('push', {
'set-upstream': true
}, [origin, newRepo._currentBranch], err => {
Expand All @@ -149,7 +150,7 @@ module.exports = function gulpGhPages(options) {
})
.catch(err => {
setImmediate(() => {
cb(new gutil.PluginError('gulp-gh-pages', err));
cb(new PluginError('gulp-gh-pages', err));
});
});
}
Expand Down
Loading