Sunday, 16 October 2022

Best possibilities to convert the gulp tasks to grunt?

As my package contains the java script folder it contains around 7 files which consist of gulp tasks, now i need to migrate those gulp tasks to grunt. As i checked the grunt overview it seems completely different then gulp.

My sample test.js file contains as below:

gulp.task('task1', function () {
    let local = glob.sync('./dist/*', {
        ignore: ['./dist/file1.ico', './dist/file2.txt']
    });
    if (local.length) shelljs.rm('-rf', local);
    shelljs.rm('-rf', ['./private', './source/files']);
    const json = glob.sync('./input.json');
    shelljs.rm('-rf', json);
});

gulp.task('task2', function () {
    shelljs.mkdir('-p', './source/files');
    shelljs.cp('-r', './source/*', './source/files');
});

gulp.task('task6', ['task1', 'task2', 'task5']);

if i changed the gulp to grunt.registerTask then it run using grunt task and it will not accept and thrown some error and my gruntfile like as below,

module.exports = function (grunt) {
    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),
        uglify: {
          options: {
            banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n'
          }
        }
      });
    grunt.registerTask('default', 'Log some stuff.', function() {
        grunt.log.write('Logging some stuff...').ok();
      });
 
};

I'm clueless to change those gulp changes into grunt, is this possible to run the grunt task from another js file? I am new to this grunt! Please help me with the possibility to migrate it.



from Best possibilities to convert the gulp tasks to grunt?

No comments:

Post a Comment