lib/runGruntfile.js
function writeShell(grunt, options, src, cwd, argArr) {
  let dir = options.writeShell;

  if (grunt.file.isFile(options.writeShell)) {
    dir = path.dirname(options.writeShell);
  }

  const gf = path.basename(src.toLowerCase(), path.extname(src));
  const base = path.join(dir, options.target + '__' + gf);

  const _ = grunt.util._;
  const gruntCli = (_.isUndefined(options.gruntCli) || _.isNull(options.gruntCli)) ? 'grunt' : options.gruntCli;

  // beh
  const shPath = base + '.sh';
  const shContent = [
    '#!/bin/bash',
    '',
    'cd ' + path.resolve(cwd),
    gruntCli + ' ' + argArr.join(' '),
    ''
  ].join('\n');
  grunt.file.write(shPath, shContent);

  //TODO chmod the shell-script?

  // semi broken
  const batPath = base + '.bat';
  const batContent = [
    'set PWD=%~dp0',
    'cd ' + path.resolve(cwd),
    gruntCli + ' ' + argArr.join(' '),
    'cd "%PWD%"',
    ''
  ].join('\r\n');
  grunt.file.write(batPath, batContent);

  console.log('argArr: ' + argArr.join(' '));
}
function writeShell(grunt, options, src, cwd, argArr) {
  let dir = options.writeShell;

  if (grunt.file.isFile(options.writeShell)) {
    dir = path.dirname(options.writeShell);
  }

  const gf = path.basename(src.toLowerCase(), path.extname(src));
  const base = path.join(dir, options.target + '__' + gf);

  const _ = grunt.util._;
  const gruntCli = (_.isUndefined(options.gruntCli) || _.isNull(options.gruntCli)) ? 'grunt' : options.gruntCli;

  // beh
  const shPath = base + '.sh';
  const shContent = [
    '#!/bin/bash',
    '',
    'cd ' + path.resolve(cwd),
    gruntCli + ' ' + argArr.join(' '),
    ''
  ].join('\n');
  grunt.file.write(shPath, shContent);

  //TODO chmod the shell-script?

  // semi broken
  const batPath = base + '.bat';
  const batContent = [
    'set PWD=%~dp0',
    'cd ' + path.resolve(cwd),
    gruntCli + ' ' + argArr.join(' '),
    'cd "%PWD%"',
    ''
  ].join('\r\n');
  grunt.file.write(batPath, batContent);

  console.log('argArr: ' + argArr.join(' '));
}
function writeShell ( grunt , options , src , cwd , argArr ) { let dir = options . writeShell ; if ( grunt . file . isFile ( options . writeShell ) ) { dir = path . dirname ( options . writeShell ) ; } const gf = path . basename ( src . toLowerCase ( ) , path . extname ( src ) ) ; const base = path . join ( dir , options . target + '__' + gf ) ; const _ = grunt . util . _ ; const gruntCli = ( _ . isUndefined ( options . gruntCli ) || _ . isNull ( options . gruntCli ) ) ? 'grunt' : options . gruntCli ; // beh const shPath = base + '.sh' ; const shContent = [ '#!/bin/bash' , '' , 'cd ' + path . resolve ( cwd ) , gruntCli + ' ' + argArr . join ( ' ' ) , '' ] . join ( '\n' ) ; grunt . file . write ( shPath , shContent ) ; //TODO chmod the shell-script? // semi broken const batPath = base + '.bat' ; const batContent = [ 'set PWD=%~dp0' , 'cd ' + path . resolve ( cwd ) , gruntCli + ' ' + argArr . join ( ' ' ) , 'cd "%PWD%"' , '' ] . join ( '\r\n' ) ; grunt . file . write ( batPath , batContent ) ; console . log ( 'argArr: ' + argArr . join ( ' ' ) ) ; }
write shell scripts
write shell scripts