diff --git a/README.md b/README.md index faf4974..c2b860f 100644 --- a/README.md +++ b/README.md @@ -27,8 +27,8 @@ Add `bucket`, `aws_key` and `aws_secret` to `deploy` in `_config.yml`. deploy: type: s3 bucket: - aws_key: - aws_secret: + aws_key: //Optional, if the environment variable `AWS_KEY` is set + aws_secret: //Optional, if the environment variable `AWS_SECRET` is set concurrency: //Optional region: //Optional, see https://github.com/LearnBoost/knox#region ``` diff --git a/index.js b/index.js index cf4e801..cfeea47 100644 --- a/index.js +++ b/index.js @@ -10,6 +10,9 @@ var public_dir = hexo.config.public_dir || './public'; hexo.extend.deployer.register('s3', function (args, callback) { var config = hexo.config.deploy; + config.aws_key = config.aws_key || process.env.AWS_KEY; + config.aws_secret = config.aws_secret || process.env.AWS_SECRET; + if (!config.bucket || !config.aws_key || !config.aws_secret){ var help = [ 'You should configure deployment settings in _config.yml first!', @@ -18,8 +21,8 @@ hexo.extend.deployer.register('s3', function (args, callback) { ' deploy:', ' type: s3', ' bucket: ', - ' aws_key: ', - ' aws_secret: ', + ' [aws_key]: # Optional, if provided as environment variable', + ' [aws_secret]: # Optional, if provided as environment variable', ' [concurrency]: ', ' [region]: # See https://github.com/LearnBoost/knox#region', '', @@ -30,7 +33,6 @@ hexo.extend.deployer.register('s3', function (args, callback) { return callback(); } - var files = readdirp({ root: public_dir, entryType: 'both'