Skip to content

Commit

Permalink
feat(array): Check, that an array of src+dest pairs works
Browse files Browse the repository at this point in the history
Fix the instrumenting step in the ceck_coverage first run.
  • Loading branch information
prantlf committed May 8, 2017
1 parent dd56fd2 commit 3e32dda
Show file tree
Hide file tree
Showing 11 changed files with 126 additions and 15 deletions.
41 changes: 35 additions & 6 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use strict';

var os = require('os'),
var fs = require('fs'),
os = require('os'),
path = require('path'),
chalk = require('chalk');

Expand All @@ -9,10 +10,12 @@ module.exports = function (grunt) {
var coverage = process.env.GRUNT_MOVE_COVERAGE,
tmp = os.tmpdir(),
succeedingTasks = [
'move:empty', 'move:missing', 'move:rename', 'move:move_with_rename',
'move:move_without_rename', 'move:move_more',
'move:move_with_wildcard', 'move:move_with_wildcard_and_cwd',
'move:move_directory', 'move:move_across_volumes'
'move:empty', 'move:missing', 'move:rename',
'move:move_with_rename', 'move:move_without_rename',
'move:move_more', 'move:move_with_wildcard',
'move:move_with_wildcard_and_cwd', 'move:move_directory',
'move:move_across_volumes', 'move:rename_multiple',
'move:move_multiple'
],
failingTasks = [
'move:failed_empty', 'move:failed_missing',
Expand Down Expand Up @@ -107,6 +110,31 @@ module.exports = function (grunt) {
src: 'test/work/move_across_volumes/file',
dest: path.join(tmp, 'grunt-move/file')
},
rename_multiple: {
files: [
{
src: 'test/work/rename_multiple/first',
dest: 'test/work/rename_multiple/third'
},
{
src: 'test/work/rename_multiple/second',
dest: 'test/work/rename_multiple/fourth'
}
]
},
move_multiple: {
files: [
{
src: ['test/work/move_multiple/source1/first',
'test/work/move_multiple/source1/second'],
dest: 'test/work/move_multiple/target1/'
},
{
src: 'test/work/move_multiple/source2/*',
dest: 'test/work/move_multiple/target2/'
}
]
},
failed_empty: {
},
failed_missing: {
Expand Down Expand Up @@ -176,7 +204,8 @@ module.exports = function (grunt) {

});

grunt.loadTasks(coverage ? 'coverage/tasks' : 'tasks');
grunt.loadTasks(coverage && fs.existsSync('coverage/tasks') ?
'coverage/tasks' : 'tasks');

grunt.loadNpmTasks('grunt-continue');
grunt.loadNpmTasks('grunt-contrib-clean');
Expand Down
28 changes: 27 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ This module provides a grunt multi-task for moving and renaming files and direct

## Installation

You need [node >= 0.10][node], [npm] and [grunt >= 0.4][Grunt] installed
You need [node >= 4][node], [npm] and [grunt >= 1][Grunt] installed
and your project build managed by a [Gruntfile] with the necessary modules
listed in [package.json]. If you haven't used Grunt before, be sure to
check out the [Getting Started] guide, as it explains how to create a
Expand Down Expand Up @@ -147,6 +147,31 @@ other tasks then.
},
src: 'test/work/move_across_volumes/file',
dest: '/tmp/grunt-move/file'
},
rename_multiple: {
files: [
{
src: 'test/work/rename_multiple/first',
dest: 'test/work/rename_multiple/third'
},
{
src: 'test/work/rename_multiple/second',
dest: 'test/work/rename_multiple/fourth'
}
]
},
move_multiple: {
files: [
{
src: ['test/work/move_more/source1/first',
'test/work/move_more/source1/second'],
dest: 'test/work/move_more/target1/'
},
{
src: 'test/work/move_more/source2/*',
dest: 'test/work/move_more/target2/'
}
]
}
}
});
Expand All @@ -160,6 +185,7 @@ your code using Grunt.

## Release History

* 2017-05-09 v0.1.0 Move multiple files in the scope of one task
* 2017-04-09 v0.0.6 Fix async dependency
* 2017-01-15 v0.0.2-5 Improve documentation
* 2017-01-15 v0.0.1 Initial release
Expand Down
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file added test/data/rename_multiple/first
Empty file.
Empty file.
72 changes: 64 additions & 8 deletions test/move_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,37 +20,51 @@ exports.move = {
},

rename: function (test) {
test.expect(1);
test.expect(2);
test.ok(!grunt.file.exists('test/work/rename/old'),
'No file with the old name exists');
test.ok(grunt.file.exists('test/work/rename/new'),
'File is renamed in the same directory');
test.done();
},

move_with_rename: function (test) {
test.expect(1);
test.expect(2);
test.ok(!grunt.file.exists('test/work/move_with_rename/source/old'),
'No file with the old name at the old location exists');
test.ok(grunt.file.exists('test/work/move_with_rename/target/new'),
'File is moved to other directory and renamed');
test.done();
},

move_without_rename: function (test) {
test.expect(1);
test.expect(2);
test.ok(!grunt.file.exists('test/work/move_without_rename/source/file'),
'No file at the old location exists');
test.ok(grunt.file.exists('test/work/move_without_rename/target/file'),
'File is moved to other directory');
test.done();
},

move_more: function (test) {
test.expect(2);
test.expect(4);
test.ok(!grunt.file.exists('test/work/move_more/source/first'),
'First file at the old location does not exist');
test.ok(grunt.file.exists('test/work/move_more/target/first'),
'First file is moved to other directory');
test.ok(!grunt.file.exists('test/work/move_more/source/second'),
'Second file at the old location does not exist');
test.ok(grunt.file.exists('test/work/move_more/target/second'),
'Second file is moved to other directory');
test.done();
},

move_with_wildcard: function (test) {
test.expect(2);
test.expect(4);
test.ok(!grunt.file.exists('test/work/move_with_wildcard/source/first'),
'First file at the old location does not exist');
test.ok(!grunt.file.exists('test/work/move_with_wildcard/source/second'),
'Second file at the old location does not exist');
test.ok(grunt.file.exists('test/work/move_with_wildcard/target/first'),
'First file is moved to other directory');
test.ok(grunt.file.exists('test/work/move_with_wildcard/target/second'),
Expand All @@ -59,7 +73,11 @@ exports.move = {
},

move_with_wildcard_and_cwd: function (test) {
test.expect(2);
test.expect(4);
test.ok(!grunt.file.exists('test/work/move_with_wildcard_and_cwd/source/first'),
'First file at the old location does not exist');
test.ok(!grunt.file.exists('test/work/move_with_wildcard_and_cwd/source/second'),
'Second file at the old location does not exist');
test.ok(grunt.file.exists('test/work/move_with_wildcard_and_cwd/target/first'),
'First file is moved to other directory');
test.ok(grunt.file.exists('test/work/move_with_wildcard_and_cwd/target/second'),
Expand All @@ -68,17 +86,55 @@ exports.move = {
},

move_directory: function (test) {
test.expect(1);
test.expect(2);
test.ok(!grunt.file.exists('test/work/move_directory/source/file'),
'No directory at the old location exists');
test.ok(grunt.file.exists('test/work/move_directory/target/file'),
'Directory is moved to other directory');
test.done();
},

move_across_volumes: function (test) {
test.expect(1);
test.expect(2);
test.ok(!grunt.file.exists('test/work/move_across_volumes/file'),
'No file at the old location exists');
test.ok(grunt.file.exists(path.join(os.tmpdir(), 'grunt-move/file')),
'File is moved across volumes');
test.done();
},

rename_multiple: function (test) {
test.expect(4);
test.ok(!grunt.file.exists('test/work/rename_multiple/first'),
'First file with the old name does not exist');
test.ok(grunt.file.exists('test/work/rename_multiple/third'),
'First file is renamed in the same directory');
test.ok(!grunt.file.exists('test/work/rename_multiple/second'),
'Second file with the old name does not exist');
test.ok(grunt.file.exists('test/work/rename_multiple/fourth'),
'Second file is renamed in the same directory');
test.done();
},

move_multiple: function (test) {
test.expect(8);
test.ok(!grunt.file.exists('test/work/move_multiple/source1/first'),
'First file at the old location does not exist');
test.ok(!grunt.file.exists('test/work/move_multiple/source1/second'),
'Second file at the old location does not exist');
test.ok(grunt.file.exists('test/work/move_multiple/target1/first'),
'First file is moved to other directory');
test.ok(grunt.file.exists('test/work/move_multiple/target1/second'),
'First file is moved to other directory');
test.ok(!grunt.file.exists('test/work/move_multiple/source2/third'),
'Third file at the old location does not exist');
test.ok(!grunt.file.exists('test/work/move_multiple/source2/fourth'),
'Fourth file at the old location does not exist');
test.ok(grunt.file.exists('test/work/move_multiple/target2/third'),
'Third file is moved to other directory');
test.ok(grunt.file.exists('test/work/move_multiple/target2/fourth'),
'Fourth file is moved to other directory');
test.done();
}

};

0 comments on commit 3e32dda

Please sign in to comment.