LoginSignup
2
2

More than 5 years have passed since last update.

gruntでコマンドライン引数を取得する

Posted at

はじめに

この記事ではgruntでコマンドライン引数を取得する方法を説明します。

grunt.optionを使いましょう

gruntにコマンドライン引数を渡すには、以下のようにします

grunt タスク名 引数名=値

そして、これをgrunt内で受け取るには、Gruntfile.jsで以下のように書きます。

grunt.option('引数名')

元ネタ
http://gruntjs.com/api/grunt.option

おわりに

手前味噌ですが、自作ゲームでgruntへのコマンドライン引数引き渡しをやってみました。コードはこんな感じです。

プロジェクト全体のコードはここです。
https://github.com/kaidouji85/gbraver/tree/e732f88190669adb31a86ebda6cb1cab58667af0

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2