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

add support for absolute path instead of .ftppass/env variables #49

Merged
merged 2 commits into from
Jul 25, 2014

Conversation

Androguide
Copy link
Contributor

To follow-up on my previous pull request (#47), this commit adds support for passing the absolute path to a JSON file in the authKey parameter instead of the .ftppass config or an environment variable.

The user can seamlessly specify either of these, the grunt task will first check for an environment variable, then a path, or finally default back to .ftppass

Example:

/home/JohnDoe/sftp/my-json-file.json

{
    "username": "your-username",
    "keyLocation": "/path/to/your/key",
    "password": "your-strong-password"
}

Gruntfile.js

"sftp-deploy": {
    build: {
       auth: {
           host: 'my-ftp.com',
           port: '5678',
           authKey: '/home/JohnDoe/sftp/my-json-file.json'
       }
      ...
    }
}

This commit adds support for passing the absolute path to a JSON file instead of the default `.ftppass` or the environment variables

**Example:**

_/home/JohnDoe/sftp/my-json-file.json_
```
{
    "username": "your-username",
    "keyLocation": "/path/to/your/key",
    "password": "your-strong-password"
}
```

_Gruntfile.js_
```
"sftp-deploy": {
    build: {
       auth: {
           host: 'my-ftp.com',
           port: '5678',
           authKey: '/home/JohnDoe/sftp/my-json-file.json'
       }
      ...
    }
}
```
} else if (fs.existsSync(inKey)) {
var tmpStr = grunt.file.read(inKey);
var retVal = null;
if (inKey !== null && tmpStr.length) retVal = JSON.parse(tmpStr);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

inKey !== null could be caught earlier in the else if expression. I think if it's missing we'll probably get an error above anyway.

@Androguide
Copy link
Contributor Author

Yeah, that's very true.
I added a commit to catch a null inKey directly and simplify/shorten the if statements quite a bit.

I've tested it with all 3 methods (.ftppass, env variables, path), and when specifying unexisting values, the errors seem to be caught properly (i.e: "Warning: .ftppass seems to be missing or incomplete")

thrashr888 added a commit that referenced this pull request Jul 25, 2014
add support for absolute path instead of .ftppass/env variables
@thrashr888 thrashr888 merged commit aa0b14f into thrashr888:master Jul 25, 2014
@thrashr888
Copy link
Owner

Looks good! Thanks.

@Androguide
Copy link
Contributor Author

No problem, thanks to you for this useful grunt task.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants