screeps / grunt-screeps

A Grunt plugin for commiting code to your Screeps account
MIT License
62 stars 36 forks source link

multiple grunt configs/tasks #15

Open JestDotty opened 7 years ago

JestDotty commented 7 years ago
module.exports = function(grunt){
  grunt.loadNpmTasks('grunt-screeps');
  grunt.initConfig({
    screeps: {
      default: {
        options: {
          email: creds.email,
          password: creds.password,
          branch: 'default',
          ptr: false
        },
        dist: {
          src: ['dist/*.js']
        }
      },
      test: {
        options: {
          email: creds.email,
          password: creds.password,
          branch: 'test',
          ptr: false
        },
        dist: {
          src: ['webpack/main.js']
        }
      }
    },
  });

  grunt.registerTask('screeps', ['screeps:default'])
  grunt.registerTask('screepsTest', ['screeps:test'])
  //grunt.registerTask('default', ['screeps'])
}

when i try to do grunt screepsTest it just hangs forever

when I googled it seems certain grunt modules allow this, others don't? If I did it wrong please tell me, too, thanks.

HontoNoRoger commented 4 years ago

I assume re-registering a task called screeps is the issue there. Try to use another another name, since screeps is already registered as multitask. Check what is actually happening with grunt --verbose screepsTest.

geoffpotter commented 3 years ago

I ran into this issue, but was able to figure out what I was doing wrong and it looks like you've made the same mistake I did. Since this is old I'm guessing you've either solved it already or moved on, but I'll post here in case it helps anyone else.

You just need to move your scr: entries up to the test: and default: level, the dist: entry is only valid as a child of the screeps: one.

here's the relevant section of my config: ` screeps: { private: { src: ['dist/*.js'], options: { server: { host: host_private, port: port_private, http: http_private }, email: email_private, password: password_private, branch: branch_private, ptr: false }, },

  public: {
    src: ['dist/*.js'],
    options: {
      email: email_public,
      password: password_public,
      branch: branch_public,
      ptr: ptr
    }
  }

},`

Basically it's just how grunt handles loading files into it's tasks via the config. With the default config in the readme, you can remove the dist element and put the src element right after the options element and it will still work. If you look at the logs, with the dist: there it says it's running screeps:dist, but without it, it will say it's running screeps:src. So adding extra configs just messes with how they choose to write the default settings block.

This is also why it hangs, it's not finding any files and it doesn't have a check for that, so it's just sitting there waiting for the for loop to call it's done function, but the for loop didn't run cuz the array is empty.