function process()

in grunt-config/custom-tasks/sign.js [47:136]


        function process() {
            if(workLoad.length <= 0) {
                globalDone();
                return;
            }

            var workItem = workLoad.pop();
            // make source file releative to cwd, since cwd is used as workdir from spawn
            var fileName =  path.relative(self.data.cwd,workItem.src);
            var taskOptions,pipeTo,pipeSrc = 'out';
            console.log (fileName);
            if ( workItem.type === 'md5' ) {
                pipeTo = workItem.src+'.md5';

                grunt.log.writeln(chalk.yellow('Signing ('+workItem.type+') ' + fileName + " ..."));
                //openssl dgst -md5 odatajs.4.0.0.nupkg
                taskOptions = { 
                    cmd : 'openssl', 
                    args: ['dgst','-md5',fileName],
                    opts : { cwd :self.data.cwd }
                };
            } else if ( workItem.type === 'sha' ) {  
                pipeTo = workItem.src+'.sha';

                grunt.log.writeln(chalk.yellow('Signing ('+workItem.type+') ' + fileName + " ..."));

                //gpg --print-md SHA512 odatajs-4.0.0-doc.zip
                taskOptions = { 
                    cmd : 'gpg', 
                    args: ['--print-md','SHA512',fileName],
                    opts : { cwd :self.data.cwd }
                };
            } else if ( workItem.type === 'asc' ) {  
                pipeTo = undefined; // done by gpg

                grunt.log.writeln(chalk.yellow('Signing ('+workItem.type+') ' + fileName + " ..."));
                
                //gpg --armor --detach-sign odatajs-4.0.0-sources.zip
                taskOptions = { 
                    cmd : 'gpg', 
                    args: ['--armor','--detach-sign',fileName],
                    opts : { cwd :self.data.cwd }
                };
            } else if ( workItem.type === 'asc-verify' ) {  
                pipeTo = 'console';
                pipeSrc = 'err';

                grunt.log.writeln(chalk.yellow('Verify ('+workItem.type+') ' +fileName+ '.asc' + " ..."));
                
                //gpg --verify --detach-sign odatajs-4.0.0-sources.zip.asc
                taskOptions = { 
                    cmd : 'gpg', 
                    args: ['--verify', fileName+'.asc'],
                    opts : { cwd :self.data.cwd }
                };
            } else { 
                grunt.fail.warn('Unknown sign type: "'+ workItem.type + '"', 1);
            }

            //console.log(taskOptions);

            var task = grunt.util.spawn(taskOptions, function done(err,result) {
                    if (err) {
                        grunt.fail.warn('Sign: '+err);
                    }
                });
            

            
            if (pipeTo) {
                if (pipeTo === 'console') {
                    if (pipeSrc ==='err') {
                        task.stderr.on('data', writeToLogOk );
                    } else {
                        task.stdout.on('data', writeToLogOk);
                    }
                } else {
                    var outStream = fs.createWriteStream(pipeTo/* ,{flags: 'w'}*/);
                    var src = (pipeSrc ==='err') ? task.stderr : task.stdout;
                    src.pipe(outStream, { end: false });
                }
            }
    
            task.on('close', function (code) {
                grunt.log.ok('Processed ('+workItem.type+') :' + workItem.src);
                grunt.log.ok('with code ' + code);
                process();
            });
            
        }