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 configuration to auto copy file remotely #138

Merged
merged 6 commits into from
Jul 19, 2018
Merged

add configuration to auto copy file remotely #138

merged 6 commits into from
Jul 19, 2018

Conversation

yungezz
Copy link
Contributor

@yungezz yungezz commented Jul 16, 2018

Summary

add new feature:
copy local saved files to remote ssh host.

Issue Type

  • New Feature

@yungezz yungezz requested review from zikalino and yuwzho July 16, 2018 10:04
this._configuration = config;
}

protected hasConfigurationChanged(oldConfig: FileCopyConfigs, newConfig: FileCopyConfigs) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This function name sounds like a function to detect whether there is change happens and the return type should be bool.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

protected hasConfigurationChanged(oldConfig: FileCopyConfigs, newConfig: FileCopyConfigs) {
let result = [];

if (!oldConfig || oldConfig.length === 0) {
Copy link
Contributor

Choose a reason for hiding this comment

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

this conditional check can be written as oldConfig = oldConfig || []. This empty check should also be applied to newConfig. And then go to the original logic to merge two array

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

public async copyFiles(configuration: FileCopyConfigs, fileName: string = null) {
let servers = utilities.getSSHConfig();

if (!configuration) {
Copy link
Contributor

Choose a reason for hiding this comment

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

configuration = configuration || this._configuration || []

return result;
}

public async copyFiles(configuration: FileCopyConfigs, fileName: string = null) {
Copy link
Contributor

Choose a reason for hiding this comment

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

where is the await?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed async

src/sshRunner.ts Outdated
// check configuration weather to sync workspace
let copyWorkspace = utilities.getCodeConfiguration<boolean>('ansible', 'copyWorkspace');
if (fileSyncConfig) {
for (let config of fileSyncConfig) {
Copy link
Contributor

Choose a reason for hiding this comment

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

for (let config of (fileSyncConfig || [])) {

src/sshRunner.ts Outdated
} catch (err) {
return;
// if not saved on copy, copy playbook to remote
if (!config.copyOnSave) {
Copy link
Contributor

Choose a reason for hiding this comment

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

what if

  1. copyOnSave = false
  2. modified some file
  3. copyOnSave = true
  4. run

Copy link
Contributor Author

Choose a reason for hiding this comment

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

run against old version.


let childTokens = [];
child.split(/\\/).forEach((s) => childTokens = childTokens.concat(s.split(/\//).filter(i => i.length)));
return parentTokens.every((t, i) => childTokens[i] === t);
Copy link
Contributor

Choose a reason for hiding this comment

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

Need wait the forEach terminate?

@yungezz yungezz merged commit f33e036 into master Jul 19, 2018
@yungezz yungezz deleted the file-watch branch July 19, 2018 03:04
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.

2 participants