Skip to content
Open
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
2 changes: 1 addition & 1 deletion .babelrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"presets": ["es2015-node4"]
"presets": ["es2015-node4", "stage-0"]
}
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,14 @@ The location on your remote machine you wish to apply changes to.

An array of file(s) or filepath(s) that, when matched, sicksync will ignore and not send changes. Editor configuration and `.git/*` files are generally ok to ignore. Uses [`anymatch`](https://github.com/es128/anymatch) for globbing.

`disableDeletion: {boolean}`

When true, this will prevent `sicksync` from deleting files on the server. Defaults to `false`. It can also be switched with the command-line switch `-D` or `--disable-deletion`

`disableRsync: {boolean}`

When true, this will prevent `sicksync` from doing rsync for any big file changes. (default: false) (command-line switch: `-R`, or `--disable-rsync`)

`websocketPort: {number}`

The port number which you want BOTH the local and remote machines to use for websocket-syncing.
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
"babel-cli": "^6.18.0",
"babel-core": "^6.18.0",
"babel-preset-es2015-node4": "^2.1.0",
"babel-preset-stage-0": "^6.22.0",
"babel-register": "^6.18.0",
"chai": "^3.2.0",
"coveralls": "^2.11.14",
Expand Down
12 changes: 9 additions & 3 deletions src/big-sync.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ export function bigSync(project) {
.source(ensureTrailingSlash(project.sourceLocation))
.destination(project.username + '@' + project.hostname + ':' + project.destinationLocation);

if (params.delete === true) {
rsync.set('delete')
if (!(params.disableDeletion || project.disableDeletion)) {
rsync.set('delete');
}

if (params.dry) {
Expand All @@ -43,5 +43,11 @@ export function bigSync(project) {
rsync.output(consoleLogFromBuffer, consoleLogFromBuffer);
}

Copy link
Contributor

Choose a reason for hiding this comment

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

nice!

rsync.execute(onComplete);
return new Promise((resolve, reject) => {
rsync.execute((err, ...result) => {
onComplete(err, ...result);
if (err) reject(err);
else resolve(...result);
});
});
}
5 changes: 3 additions & 2 deletions src/commands/start.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ function sicksyncStartCommand(program, config) {
program
.command('start [projects...]')
.description('Starts the continuous sicksync process for the given project(s)')
.option('-D, --no-delete', 'Do not delete remote files on inital rsync')
.option('-D, --disable-deletion', 'Do not delete files on the server')
.option('-R, --disable-rsync', 'Do not do rsync on bigger file changes')
.action((projects, options) =>
start(_.extend(config, _.pick(options, ['delete'])), projects))
start(_.extend(config, _.pick(options, ['disableDeletion', 'disableRsync'])), projects));
}

export default sicksyncStartCommand;
52 changes: 28 additions & 24 deletions src/local/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,16 @@ const hostname = os.hostname();
const wsEvents = eventsConf.WS.LOCAL;
const fsEvents = eventsConf.FS.LOCAL;

function triggerBigSync(project, params, cb) {
bigSync({
function triggerBigSync(project, params) {
return bigSync({
project: project.project,
excludes: project.excludes,
sourceLocation: ensureTrailingSlash(project.sourceLocation),
destinationLocation: ensureTrailingSlash(project.destinationLocation),
hostname: project.hostname,
username: project.username,
}, params, cb);
disableDeletion: project.disableDeletion,
}, params);
}

export function start(config, projects) {
Expand Down Expand Up @@ -79,16 +80,16 @@ function startProject(config, projectConf) {
});

// WS events
wsClient.on(wsEvents.READY, () => {
triggerBigSync(projectConf, _.pick(config, ['debug', 'delete']), () => {
fsHelper.watch();

localLog(
text.SYNC_ON_CONNECT,
projectConf.hostname, (projectConf.prefersEncrypted) ? 'using' : 'not using',
'encryption'
);
});
wsClient.on(wsEvents.READY, async () => {
if (!(config.disableRsync || projectConf.disableRsync)) {
await triggerBigSync(projectConf, _.pick(config, ['debug', 'delete']));
}
fsHelper.watch();
localLog(
text.SYNC_ON_CONNECT,
projectConf.hostname, (projectConf.prefersEncrypted) ? 'using' : 'not using',
'encryption'
);
});

wsClient.on(wsEvents.RECONNECTING, _.partial(_.ary(localLog, 1), text.SYNC_ON_RECONNECT));
Expand Down Expand Up @@ -121,14 +122,14 @@ function startProject(config, projectConf) {
wsClient.send(fileChange);
});

fsHelper.on(fsEvents.LARGE, () => {
fsHelper.on(fsEvents.LARGE, async () => {
localLog(text.SYNC_ON_LARGE_CHANGE);
fsHelper.pauseWatch();

triggerBigSync(projectConf, { debug: config.debug }, () => {
localLog(text.SYNC_ON_LARGE_CHANGE_DONE);
fsHelper.watch();
});
if (!(config.disableRsync || projectConf.disableRsync)) {
await triggerBigSync(projectConf, { debug: config.debug });
}
localLog(text.SYNC_ON_LARGE_CHANGE_DONE);
fsHelper.watch();
});
}

Expand All @@ -139,15 +140,18 @@ export function once(config, projects, opts) {
return logProjectsNotFound(foundProjects);
}

_.each(foundProjects, (project) => {
_.each(foundProjects, async (project) => {
const localLog = generateLog(project.project, hostname);

localLog(text.SYNC_ON_ONCE);

triggerBigSync(project, {
dry: opts.dryRun,
debug: config.debug,
}, _.partial(localLog, text.SYNC_ON_ONCE_DONE));
if (!(config.disableRsync || project.disableRsync)) {
await triggerBigSync(project, {
dry: opts.dryRun,
debug: config.debug,
});
}
localLog(text.SYNC_ON_ONCE_DONE);
});
}

Expand Down
10 changes: 10 additions & 0 deletions src/project-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,16 @@ export const add = (config) => {
before: util.toBoolean,
default: 'no',
},
disableDeletion: {
description: 'Prevent sicksync from deleting files on the remote server? (yes/no):',
before: util.toBoolean,
default: 'no',
},
disableRsync: {
description: 'Prevent sicksync from doing rsync on big file changes? (yes/no):',
default: 'no',
before: util.toBoolean,
},
websocketPort: {
description: 'What port should sicksync use for this project?',
default: 8675,
Expand Down