Skip to content

Commit

Permalink
Call gh-pages with parsed options 📖
Browse files Browse the repository at this point in the history
  • Loading branch information
JaZo committed Oct 10, 2018
1 parent 873e1b8 commit 3ffaf8c
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
31 changes: 27 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ module.exports = (api, projectOptions) => {
'-n, --no-push': `Commit only (with no push)`,
' --help': `Output usage information`
}
}, args => {
}, async args => {
const pluginOptions = projectOptions.pluginOptions ? projectOptions.pluginOptions.ghPages || {} : {};

let dir = args.d || args.dist || pluginOptions.dir || projectOptions.outputDir;
Expand Down Expand Up @@ -56,8 +56,31 @@ module.exports = (api, projectOptions) => {
user: user || pluginOptions.user,
};

console.log(dir);
console.log(api.resolve(dir));
console.log(options);
await deploy(api, api.resolve(dir), options);
})
};

async function deploy(api, dir, options) {
const path = require('path');
const ghpages = require('gh-pages');
const {chalk, log, done, logWithSpinner, stopSpinner} = require('@vue/cli-shared-utils');

log();
const dirShort = path.relative(api.service.context, dir);
logWithSpinner(`Deploying ${chalk.cyan(dirShort)} to GitHub Pages...`);

return new Promise((resolve, reject) => {
ghpages.publish(dir, options, err => {
stopSpinner(false);
if (err) {
return reject(err)
}

if (!options.silent) {
done(`Deployment complete.`);
}

resolve();
});
});
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"license": "MIT",
"main": "index.js",
"dependencies": {
"@vue/cli-shared-utils": "^3.0.5",
"email-addresses": "^3.0.2",
"gh-pages": "^2.0.0"
}
Expand Down

0 comments on commit 3ffaf8c

Please sign in to comment.