I'm writing a gulp task to do the following:
- Watch an image file for changes
- If image file has changed, copy the contents of the image to the clipboard, ready for me to paste.
Note: I'm on Windows and am using nircmd.exe to do the copy of the image contents. The following command line works for me:
nircmd.exe clipboard copyimage "G:\IMG\pic.png"
I've put this into a .bat file so I can run the file via commandline.
My gulpfile (so far):
var gulp = require('gulp'),
watch = require('gulp-watch'),
shell = require('gulp-shell'),
run = require('gulp-run'),
clipboard = require("gulp-clipboard"),
myTerminal = require("child_process").exec,
commandToBeExecuted = "./copy-to-clipboard.bat";
gulp.task('copy-to-clipboard', function () {
require('child_process').spawn('cmd', ['/s', '/c', '"G:\\Git\\copy-to-clipboard\\copy-to-clipboard.bat"'], {
windowsVerbatimArguments: true
});
});
gulp.task('default', function () {
watch('watch/*.png','copy-to-clipboard');
});
I've tried gulp-shell but since this opens a node terminal, nircmd.exe is not recognised as an internal or external command.
I've also tried child_process (both spawn and exec), but while I get no errors, the contents are still not in the clipboard.
Is there an easier way or is this just not possible?
Thanks in advance!