Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

grunt-sync

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

grunt-sync - npm Package Compare versions

Comparing version 0.1.1 to 0.2.0

96

package.json
{
"name": "grunt-sync",
"description": "Task to synchronize two directories. Similar to grunt-copy but updates only files that have been changed.",
"version": "0.1.1",
"homepage": "https://github.com/tomusdrw/grunt-sync.git",
"author": {
"name": "Tomasz Drwiega",
"email": "tomusdrw@blacksoft.eu",
"url": "http://blacksoft.eu"
},
"repository": {
"type": "git",
"url": "git://github.com/tomusdrw/grunt-sync.git"
},
"bugs": {
"url": "https://github.com/tomusdrw/grunt-sync/issues"
},
"licences": [
{
"type": "MIT",
"url": "http://opensource.org/licenses/MIT"
}
],
"main": "Gruntfile.js",
"readmeFilename": "readme.md",
"engines": {
"node": ">=0.8.0"
},
"scripts": {
"test": "mocha"
},
"dependencies": {
"glob": "^4.0.5",
"promised-io": "0.3.3"
},
"devDependencies": {
"chai": "1.4.2",
"grunt": "0.4.x",
"grunt-complexity": "^0.1.51",
"grunt-contrib-jshint": "0.1.x",
"grunt-simple-mocha": "0.3.x",
"mocha": "~1.8.1",
"time-grunt": "^0.4.0"
},
"keywords": [
"gruntplugin",
"sync",
"synchronize",
"copy"
]
"name": "grunt-sync",
"description": "Task to synchronize two directories. Similar to grunt-copy but updates only files that have been changed.",
"version": "0.2.0",
"homepage": "https://github.com/tomusdrw/grunt-sync.git",
"author": {
"name": "Tomasz Drwiega",
"email": "tomusdrw@blacksoft.eu",
"url": "http://blacksoft.eu"
},
"repository": {
"type": "git",
"url": "git://github.com/tomusdrw/grunt-sync.git"
},
"bugs": {
"url": "https://github.com/tomusdrw/grunt-sync/issues"
},
"licences": [{
"type": "MIT",
"url": "http://opensource.org/licenses/MIT"
}],
"main": "Gruntfile.js",
"readmeFilename": "readme.md",
"engines": {
"node": ">=0.8.0"
},
"scripts": {
"test": "mocha"
},
"dependencies": {
"glob": "^4.0.5",
"promised-io": "0.3.3"
},
"devDependencies": {
"chai": "1.4.2",
"grunt": "0.4.x",
"grunt-complexity": "^0.1.51",
"grunt-contrib-jshint": "0.1.x",
"grunt-simple-mocha": "0.3.x",
"mocha": "~1.8.1",
"time-grunt": "^0.4.0"
},
"keywords": [
"gruntplugin",
"sync",
"synchronize",
"copy"
]
}

@@ -28,4 +28,3 @@ # Grunt-sync

}],
ignoreInDest: "**/*.js", // Never remove js files from destination
pretend: true, // Don't do any IO. Before you run the task make sure it doesn't remove too much.
pretend: true, // Don't do any IO. Before you run the task with `updateAndDelete` PLEASE MAKE SURE it doesn't remove too much.
verbose: true // Display log messages when copying files

@@ -51,3 +50,4 @@ }

pretend: true, // Don't do any disk operations - just write log
updateOnly: true // Don't remove any files from `dest` (works around 30% faster)
ignoreInDest: "**/*.js", // Never remove js files from destination
updateAndDelete: true // Remove all files from desc that are not found in src

@@ -58,7 +58,19 @@ }

## Installation
```
npm install grunt-sync --save
```
## Changelog
* 0.2.0 - Default configuration will not remove any files any more. You have to specify `updateAndDelete` option to remove any files from destination.
* 0.1.2 - Deleting all files in destination on Windows solved.
* 0.1.1 - Fixed issue with trailing slash in destination.
* 0.1.0 - Files missing that are not in `src` are deleted from `dest` (unless you specify `updateOnly`)
## Migration 0.1.x -> 0.2.x
In version 0.2 you have to explicitly specify that you want the plugin to remove files from destination. See `updateAndDelete` option and run with `pretend:true` first to make sure that it doesn't remove any crucial files. You can tune what files should be left untouched with `ignoreInDest` property.
If you have `updateOnly:true` in your 0.1 config you can remove this option. For those who used `updateOnly:false` you have to include `updateAndDelete:true` in 0.2 config to keep the same behavior.
## TODO
Research if it's possible to have better integration with `grunt-contrib-watch` - update only changed files instead of scanning everything.
Research if it's possible to have better integration with `grunt-contrib-watch` - update only changed files instead of scanning everything.

@@ -5,3 +5,3 @@ {

"src": ["**"],
"dest": "bin/to",
"dest": "bin/to/",
"expand": true,

@@ -11,6 +11,7 @@ "cwd": "bin/from"

"ignoreInDest": ["t", "*.js"],
"updateOnly": false,
"updateAndDelete": true,
"verbose": true,
"pretend": true
}
}
}

@@ -9,4 +9,5 @@ {

"verbose": true,
"pretend": true
"pretend": true,
"updateAndDelete": true
}
}
}

@@ -155,6 +155,12 @@ var fs = require('promised-io/fs'),

var convertPathsToSystemSpecific = function(paths) {
return paths.map(function(filePath) {
return path.join.apply(path, filePath.split('/'));
});
};
grunt.registerMultiTask('sync', 'Synchronize content of two directories.', function() {
var done = this.async(),
logger = grunt[this.data.verbose ? 'log' : 'verbose'],
updateOnly = !!this.data.updateOnly,
updateOnly = !this.data.updateAndDelete,
justPretend = !!this.data.pretend,

@@ -166,3 +172,7 @@ ignoredPatterns = this.data.ignoreInDest,

var getExpandedPaths = function(origDest) {
expandedPaths[origDest] = expandedPaths[origDest] || [];
if (!expandedPaths[origDest]) {
// Always include destination as processed.
expandedPaths[origDest] = [origDest.replace(new RegExp("\\" + path.sep + "$"), '')];
return expandedPaths[origDest]
}
return expandedPaths[origDest];

@@ -177,4 +187,2 @@ };

var processedDestinations = getExpandedPaths(origDest);
// Always include destination as processed.
processedDestinations.push(origDest.substr(0, origDest.length - 1));

@@ -239,3 +247,3 @@ return promise.all(fileDef.src.map(function(src) {

return promise.all(Object.keys(expandedPaths).map(function(dest) {
var processedDestinations = expandedPaths[dest];
var processedDestinations = convertPathsToSystemSpecific(expandedPaths[dest]);

@@ -249,6 +257,9 @@ // We have to do second pass to remove objects from dest

return promise.all([destPaths, ignoredPaths]).then(function(result) {
var paths = convertPathsToSystemSpecific(result[0]);
var ignoredPaths = convertPathsToSystemSpecific(result[1]);
// Calculate diff
var toRemove = fastArrayDiff(result[0], processedDestinations);
var toRemove = fastArrayDiff(paths, processedDestinations);
// And filter also ignored paths
toRemove = fastArrayDiff(toRemove, result[1]);
toRemove = fastArrayDiff(toRemove, ignoredPaths);
return removePaths(justPretend, logger, toRemove);

@@ -259,2 +270,2 @@ });

});
};
};
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc