Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Summarize output by default (transactions available via --verbose) #62

Closed
wants to merge 3 commits into from

5 participants

@ericclemmons

I had a version of this already going in grunt-verbosity, so I went ahead & moved it over here.

It will spit out something like Created N directories, copied M files. Passing --verbose will spit out the usual output alongside the rest of the noise :)

I hope you don't mind, @geddski.

/cc @doowb, @jonschlinkert, @tkellen.


Before

 ~ ⮁ Sites ⮁ ericclemmons ⮁ grunt-contrib-copy ⮀ master ⮀ $ ⮀grunt test
Running "clean:test" (clean) task
Cleaning "tmp"...OK

Running "copy:main" (copy) task
Copying test/fixtures/test.js -> tmp/copy_test_files/test.js
Copying test/fixtures/test2.js -> tmp/copy_test_files/test2.js
Creating tmp/copy_test_mix/
Creating tmp/copy_test_mix/empty_folder
Creating tmp/copy_test_mix/folder_one
Copying test/fixtures/folder_one/one.js -> tmp/copy_test_mix/folder_one/one.js
Creating tmp/copy_test_mix/folder_two
Copying test/fixtures/folder_two/two.js -> tmp/copy_test_mix/folder_two/two.js
Copying test/fixtures/test.js -> tmp/copy_test_mix/test.js
Copying test/fixtures/test2.js -> tmp/copy_test_mix/test2.js
Copying test/fixtures/folder_one/one.js -> tmp/copy_test_v0.1.0/folder_one/one.js

Running "copy:flatten" (copy) task
Copying test/fixtures/folder_one/one.js -> tmp/copy_test_flatten/one.js
Copying test/fixtures/folder_two/two.js -> tmp/copy_test_flatten/two.js
Copying test/fixtures/test.js -> tmp/copy_test_flatten/test.js
Copying test/fixtures/test2.js -> tmp/copy_test_flatten/test2.js

Running "copy:single" (copy) task
Copying test/fixtures/test.js -> tmp/single.js

Running "nodeunit:tests" (nodeunit) task
Testing copy_test.js...OK
>> 5 assertions passed (5ms)

Done, without errors.

Yuck!

After

 ~ ⮁ Sites ⮁ ericclemmons ⮁ grunt-contrib-copy ⮀ 57-summary ⮀ $ ⮀grunt test
Running "clean:test" (clean) task
Cleaning "tmp"...OK

Running "copy:main" (copy) task
Created 4 directories, copied 7 files

Running "copy:flatten" (copy) task
Copied 4 files

Running "copy:single" (copy) task
Copied 1 files

Running "copy:verbose" (copy) task
Created 4 directories, copied 4 files

Running "nodeunit:tests" (nodeunit) task
Testing copy_test.js...OK
>> 5 assertions passed (4ms)

Done, without errors.

Yum!


Refs #44 & #57

@jonschlinkert

:+1: output looks great

@geddski
Collaborator

Don't mind a bit, nicely done.

@geddski
Collaborator

@tkellen LGTM, certainly cleans up the Angular build output.

@geddski geddski referenced this pull request
Closed

add summary option #57

@tkellen
Owner

Other than missing documentation (needs to be added to docs/copy-options.md) and squashing the commits, this looks great. I'd be happy to merge today if we can get those things handled.

@ericclemmons

@tkellen I'm confused on the part about copy-options. Did you intend for there to be a verbose Option within the Gruntfile? As it stands now, it pivots off of the --verbose flag from the CLI: grunt copy vs. grunt copy --verbose

Do you want all 3 (potentially 4 with the copy-options discussion) commits squashed, or just the first two? (It doesn't make sense to me to squash the version bump) Either way, whatever ya want!

@tkellen
Owner

@ericclemmons Whoops, I didn't notice the final commit. Could you drop that one please? Our READMEs are generated dynamically--that annotation needs to be entered as valid yaml in our CHANGELOG.

Sorry if I was unclear about the documentation. No, I wasn't expecting a new option, but it seems prudent to mention somewhere that --verbose is needed for a full file listing, only because we're changing the default behavior. Maybe it makes more sense to add that in the overview doc.

@tkellen tkellen closed this in 7f21fd7
@tkellen
Owner

Nevermind. I'll wrap this up from here. Thanks @ericclemmons!

@ericclemmons

Beat me to it :) Thanks for the help @tkellen, glad to give back!

@KOGI

+1 Thank you, guys!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 26 additions and 3 deletions.
  1. +6 −0 Gruntfile.js
  2. +1 −0  README.md
  3. +1 −1  package.json
  4. +18 −2 tasks/copy.js
View
6 Gruntfile.js
@@ -57,6 +57,12 @@ module.exports = function(grunt) {
files: [
{src: ['test/fixtures/test.js'], dest: 'tmp/single.js'}
]
+ },
+
+ verbose: {
+ files: [
+ {expand: true, src: ['test/fixtures/**'], dest: 'tmp/copy_test_verbose/'}
+ ]
}
},
View
1  README.md
@@ -57,6 +57,7 @@ copy: {
## Release History
+ * 2013-02-14   v0.4.1   Output summary by default ("Copied N files, created M folders"). Individual transaction output available via `--verbose`.
* 2013-02-14   v0.4.0   First official release for Grunt 0.4.0.
* 2013-01-22   v0.4.0rc7   Updating grunt/gruntplugin dependencies to rc7. Changing in-development grunt/gruntplugin dependency versions from tilde version ranges to specific versions.
* 2013-01-13   v0.4.0rc5   Updating to work with grunt v0.4.0rc5. Conversion to grunt v0.4 conventions. Replace basePath with cwd. Empty directory support.
View
2  package.json
@@ -1,7 +1,7 @@
{
"name": "grunt-contrib-copy",
"description": "Copy files and folders.",
- "version": "0.4.0",
+ "version": "0.4.1",
"homepage": "https://github.com/gruntjs/grunt-contrib-copy",
"author": {
"name": "Grunt Team",
View
20 tasks/copy.js
@@ -29,6 +29,10 @@ module.exports = function(grunt) {
var dest;
var isExpandedPair;
+ var tally = {
+ dirs: 0,
+ files: 0
+ };
this.files.forEach(function(filePair) {
isExpandedPair = filePair.orig.expand || false;
@@ -41,14 +45,26 @@ module.exports = function(grunt) {
}
if (grunt.file.isDir(src)) {
- grunt.log.writeln('Creating ' + dest.cyan);
+ grunt.verbose.writeln('Creating ' + dest.cyan);
grunt.file.mkdir(dest);
+ tally.dirs++;
} else {
- grunt.log.writeln('Copying ' + src.cyan + ' -> ' + dest.cyan);
+ grunt.verbose.writeln('Copying ' + src.cyan + ' -> ' + dest.cyan);
grunt.file.copy(src, dest, copyOptions);
+ tally.files++;
}
});
});
+
+ if (tally.dirs) {
+ grunt.log.write('Created ' + tally.dirs.toString().cyan + ' directories');
+ }
+
+ if (tally.files) {
+ grunt.log.write((tally.dirs ? ', copied ' : 'Copied ') + tally.files.toString().cyan + ' files');
+ }
+
+ grunt.log.writeln();
});
var detectDestType = function(dest) {
Something went wrong with that request. Please try again.