как использовать Gruntfile.ls (livescript Grunt)

Я хочу написать свой Gruntfile.js с помощью livescript.

Я сделал Gruntfile.js и Gruntfile.coffee, которые работают из коробки

Gruntfile.ls должно работать ... верно?

Я видел несколько Gruntfile.ls в сети, или нужно ли их компилировать (кроме версии .coffee)?

Livescript

(Ошибка при вызове $ grunt)

A valid Gruntfile could not be found. Please see the getting started guide for
more information on how to configure grunt: http://gruntjs.com/getting-started
Fatal error: Unable to find Gruntfile.

Gruntfile.ls

#global module:false

module.exports = (grunt) ->

  # Project configuration.
  grunt.init-config {}=

    meta:
      version: \0.0.1

    livescript:
      src:
        files:
          "build/js/main.js": "src/scripts/main.ls"

    watch:
     livescript:
        files: <[src/scripts/**/*.ls]>
        tasks: <[livescript]>
        options: {+livereload}

  # load tasks
  grunt.loadNpmTasks \grunt-livescript
  grunt.loadNpmTasks \grunt-contrib-watch

  # register tasks
  grunt.registerTask \default, <[livescript]>

составлено:

(работает при звонке $ grunt)

Gruntfile.js

module.exports = function(grunt){
  grunt.initConfig({
    meta: {
      version: '0.0.1'
    },
    livescript: {
      src: {
        files: {
          "build/js/main.js": "src/scripts/main.ls"
        }
      }
    },
    watch: {
      livescript: {
        files: ['src/scripts/**/*.ls'],
        tasks: ['livescript'],
        options: {
          livereload: true
        }
      }
    }
  });
  grunt.loadNpmTasks('grunt-livescript');
  grunt.loadNpmTasks('grunt-contrib-watch');
  return grunt.registerTask('default', ['livescript']);
};

person Community    schedule 03.04.2014    source источник
comment
AFAIK только JavaScript и CoffeeScript поддерживаются Grunt, но написание Gruntfile.js, которое компилирует ваш Gruntfile.ls, а затем запускает его с теми же аргументами, должно выполнить свою работу.   -  person jgillich    schedule 04.04.2014
comment
Я так и подумал ... раз уж это задокументировано grunt. Было просто интересно, почему есть проекты, которые используют livescript Gruntfile, например github.com/mndvns /polygon/blob/master/Gruntfile.ls Кстати. Я клонировал это репо и, конечно же, выдает ту же ошибку. Просто не смог найти в этом репо файл, который компилирует Gruntfile.ls в JavaScript   -  person    schedule 04.04.2014
comment
Они могут делать это вручную, по крайней мере, .gitignore указывает, что они на самом деле компилируют его, а не запускают напрямую.   -  person jgillich    schedule 04.04.2014
comment
Так что в основном мне нужно запустить livescript -c Gruntfile.ls && grunt ... хм ?? это делает меня счастливым? не совсем .. вздох ну по крайней мере работает   -  person    schedule 04.04.2014
comment
ах .. мило ... Я пропустил файл .gitignore. Спасибо   -  person    schedule 04.04.2014
comment
Ну а пока я сделал псевдоним в моем .bash_profile - ›alias gruntls='livescript -c Gruntfile.ls && grunt' спасибо за помощь   -  person    schedule 04.04.2014


Ответы (2)


Используйте это как свой Gruntfile.js:

require('LiveScript');

module.exports = function (grunt) {
    require('./Gruntfile.ls')(grunt);
}

Требуется пакет LiveScript от npm.

person jgillich    schedule 03.04.2014
comment
используйте require('livescript'); для новых версий livescript. - person ceremcem; 29.06.2016

Я предпочитаю хранить основной файл Gruntfile в js, а задачи - в ls.

Пример настройки:

require("LiveScript")
module.exports = function(grunt){
  require('load-grunt-tasks')(grunt) // autoload npmtasks from package.json
  require('load-grunt-config')(grunt) // lets you keep each task in separate file
}

На самом деле я использую свою собственную вилку load-grunt-config, расположенную на https://github.com/wolfflow/load-grunt-config/tree/beta/0.8.0

если вы хотите попробовать, просто добавьте следующую строку в свой файл package.json:

"load-grunt-config": "git://github.com/wolfflow/load-grunt-config.git#beta/0.8.0"

а затем запустите npm install.

person Daniel K    schedule 10.04.2014
comment
Фактически, Gruntfile.js может быть короче события: require("LiveScript");module.exports = require('load-grunt-config') (load-grunt-config уже включает load-grunt-tasks) - person Daniel K; 21.08.2014