Launch Week Day 5: Introducing Reachability for PHP.Learn More
Socket
Book a DemoSign in
Socket

grunt-contrib-symlink

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

grunt-contrib-symlink - npm Package Compare versions

Comparing version
0.2.0
to
0.3.0
+7
-3
package.json
{
"name": "grunt-contrib-symlink",
"description": "Create symbolic links.",
"version": "0.2.0",
"version": "0.3.0",
"homepage": "https://github.com/gruntjs/grunt-contrib-symlink",

@@ -23,3 +23,2 @@ "author": {

],
"main": "Gruntfile.js",
"engines": {

@@ -36,3 +35,4 @@ "node": ">= 0.8.0"

"grunt-contrib-internal": "~0.4.5",
"grunt": "~0.4.1"
"grunt": "~0.4.1",
"grunt-contrib-copy": "~0.4.1"
},

@@ -49,3 +49,7 @@ "peerDependencies": {

"symbolic"
],
"files": [
"tasks",
"LICENSE-MIT"
]
}

@@ -1,2 +0,2 @@

# grunt-contrib-symlink
# grunt-contrib-symlink v0.3.0

@@ -37,2 +37,6 @@ > Create symbolic links.

symlink: {
// Enable overwrite to delete symlinks before recreating them
options: {
overwrite: false
},
// The "build/target.txt" symlink will be created and linked to

@@ -54,2 +58,3 @@ // "source/target.txt". It should appear like this in a file listing:

expand: true,
overwrite: false,
cwd: 'source',

@@ -63,2 +68,3 @@ src: ['foo-*'],

expand: true,
overwrite: false,
cwd: 'source',

@@ -74,5 +80,19 @@ src: ['*'],

#### CLI overwrite option
To override the overwrite option via the CLI pass it as an option
```shell
grunt symlink --overwrite
```
#### Usage tips on Microsoft Windows
Make sure your command prompt has administrative privileges, otherwise
the task will not work.
## Release History
* 2014-02-01   v0.3.0   Fixed symlinking to '.' Add Windows usage hints. Added error logging and force failure when unable to create a symlink
* 2013-07-26   v0.2.0   Initial release as rewritten, officially-maintained, contrib plugin.

@@ -86,2 +106,2 @@ * 2012-12-21   v0.1.1   Unofficial release.

*This file was generated on Mon Jul 29 2013 12:12:23.*
*This file was generated on Sat Feb 01 2014 23:58:37.*

@@ -19,2 +19,11 @@ /*

var linkCount = 0;
// default options
var options = this.options({
overwrite: false
});
// overwrite options from CLI
options.overwrite = grunt.option('overwrite') || options.overwrite;
this.files.forEach(function(f) {

@@ -27,4 +36,7 @@ var srcpath = f.src[0];

} else if (grunt.file.exists(destpath)) {
grunt.log.warn('Destination ' + destpath + ' already exists.');
return;
if (!options.overwrite) {
grunt.log.warn('Destination ' + destpath + ' already exists.');
return;
}
grunt.file.delete(destpath);
}

@@ -37,3 +49,3 @@ // Strip any trailing slashes.

if (!grunt.file.isPathAbsolute(srcpath)) {
srcpath = path.relative(destdir, srcpath);
srcpath = path.relative(destdir, srcpath) || '.';
}

@@ -52,2 +64,4 @@ // Create any necessary interim directories.

grunt.verbose.error();
grunt.log.error(e);
grunt.fail.warn('Failed to create symlink: ' + '(' + mode + ') ' + destpath + ' -> ' + srcpath + '.');
}

@@ -54,0 +68,0 @@ linkCount++;

{
"curly": true,
"eqeqeq": true,
"immed": true,
"latedef": true,
"newcap": true,
"noarg": true,
"sub": true,
"undef": true,
"boss": true,
"eqnull": true,
"node": true
}

Sorry, the diff of this file is not supported yet

"Cowboy" Ben Alman (http://benalman.com/)
v0.2.0:
date: 2013-07-26
changes:
- Initial release as rewritten, officially-maintained, contrib plugin.
v0.1.1:
date: 2012-12-21
changes:
- Unofficial release.
v0.1.0:
date: 2012-12-20
changes:
- Unofficial release.
Please see the [Contributing to grunt](http://gruntjs.com/contributing) guide for information on contributing to this project.
# Usage Examples
```js
symlink: {
// The "build/target.txt" symlink will be created and linked to
// "source/target.txt". It should appear like this in a file listing:
// build/target.txt -> ../source/target.txt
explicit: {
src: 'source/target.txt',
dest: 'build/target.txt'
},
// These examples using "expand" to generate src-dest file mappings:
// http://gruntjs.com/configuring-tasks#building-the-files-object-dynamically
expanded: {
files: [
// All child files and directories in "source", starting with "foo-" will
// be symlinked into the "build" directory, with the leading "source"
// stripped off.
{
expand: true,
cwd: 'source',
src: ['foo-*'],
dest: 'build'
},
// All child directories in "source" will be symlinked into the "build"
// directory, with the leading "source" stripped off.
{
expand: true,
cwd: 'source',
src: ['*'],
dest: 'build',
filter: 'isDirectory'
}
]
},
}
```
Task targets, files and options may be specified according to the grunt [Configuring tasks](http://gruntjs.com/configuring-tasks) guide. Pay special attention to the [Building the files object dynamically](http://gruntjs.com/configuring-tasks#building-the-files-object-dynamically) section, which explains how to create many src-dest file mappings all at once.
Note that the symlink mode (file, dir) is determined automatically based on the src file type.
/*
* grunt-contrib-symlink
* https://github.com/gruntjs/grunt-contrib-symlink
*
* Copyright (c) 2013 Grunt Team
* Licensed under the MIT license.
*/
'use strict';
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
jshint: {
all: [
'Gruntfile.js',
'tasks/*.js',
'<%= nodeunit.tests %>',
],
options: {
jshintrc: '.jshintrc',
},
},
// Before generating any new files, remove any previously-created files.
clean: {
tests: ['tmp'],
},
// Configuration to be run (and then tested).
symlink: {
explicit: {
src: 'test/fixtures/baz.txt',
dest: 'tmp/baz.txt'
},
dirs: {
files: [
{
expand: true,
src: 'test/fixtures/*',
dest: 'tmp/dirs',
filter: 'isDirectory',
}
],
},
files: {
files: [
{
expand: true,
src: 'test/fixtures/*.txt',
dest: 'tmp/files',
}
],
},
cwd: {
files: [
{
expand: true,
cwd: 'test/fixtures',
src: '*',
dest: 'tmp/cwd',
}
],
},
},
// Unit tests.
nodeunit: {
tests: ['test/*_test.js'],
},
});
// Actually load this plugin's task(s).
grunt.loadTasks('tasks');
// These plugins provide necessary tasks.
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-nodeunit');
grunt.loadNpmTasks('grunt-contrib-internal');
// Whenever the "test" task is run, first clean the "tmp" dir, then run this
// plugin's task(s), then test the result.
grunt.registerTask('test', ['clean', 'symlink', 'nodeunit']);
// By default, lint and run all tests.
grunt.registerTask('default', ['jshint', 'test', 'build-contrib']);
};
bar!
'use strict';
var grunt = require('grunt');
/*
======== A Handy Little Nodeunit Reference ========
https://github.com/caolan/nodeunit
Test methods:
test.expect(numAssertions)
test.done()
Test assertions:
test.ok(value, [message])
test.equal(actual, expected, [message])
test.notEqual(actual, expected, [message])
test.deepEqual(actual, expected, [message])
test.notDeepEqual(actual, expected, [message])
test.strictEqual(actual, expected, [message])
test.notStrictEqual(actual, expected, [message])
test.throws(block, [error], [message])
test.doesNotThrow(block, [error], [message])
test.ifError(value)
*/
exports.symlink = {
explicit: function(test) {
test.expect(1);
test.equal(grunt.file.read('tmp/baz.txt'), 'baz!', 'should be the fixture file.');
test.done();
},
dirs: function(test) {
test.expect(2);
test.equal(grunt.file.read('tmp/dirs/test/fixtures/foo/file.txt'), 'foo!', 'should be the fixture file.');
test.equal(grunt.file.read('tmp/dirs/test/fixtures/bar/file.txt'), 'bar!', 'should be the fixture file.');
test.done();
},
files: function(test) {
test.expect(2);
test.equal(grunt.file.read('tmp/files/test/fixtures/baz.txt'), 'baz!', 'should be the fixture file.');
test.equal(grunt.file.read('tmp/files/test/fixtures/qux.txt'), 'qux!', 'should be the fixture file.');
test.done();
},
cwd: function(test) {
test.expect(4);
test.equal(grunt.file.read('tmp/cwd/foo/file.txt'), 'foo!', 'should be the fixture file.');
test.equal(grunt.file.read('tmp/cwd/bar/file.txt'), 'bar!', 'should be the fixture file.');
test.equal(grunt.file.read('tmp/cwd/baz.txt'), 'baz!', 'should be the fixture file.');
test.equal(grunt.file.read('tmp/cwd/qux.txt'), 'qux!', 'should be the fixture file.');
test.done();
},
};