npm install -g grunt-initでgrunt-initをインストール。- 空のディレクトリで
grunt-init gruntpluginを実行する。 - 開発環境用意のため
npm installを実行する。 - プラグインを作成する
- npmに公開するために
npm publishを実行する。
"grunt-contrib"の名前空間はgruntの開発チームで使用しているので、その意図に沿った適切な名前をプラグインに付けるように。
gruntは標準ではエラーの出力を表示しないが、--stackをオプションに指定することでデバッグを容易にする。常にエラーを出力するようにしたい場合は、shellでエイリアスをつくる。bashなら、alias grunt='grunt --stack'。
プラグインのファイルはプロジェクトルートの.grunt/[npm-module-name]/に配置し、作り終えたら整理する。This is not a solution for temporary scratch files, use one of the common npm modules (eg temporary, tmp) that take advantage of the OS level temporary directories for that case.
デフォルトではgruntfileが置かれたディレクトリがワーキングディレクトリになる。gruntfileでgrunt.file.setBase()を用いてワーキングディレクトリを変更できるが、プラグインでは変更しないように注意。
gruntfileでの相対パス"foo"は、path.resolve('foo')で絶対パスを取得できるようになっている。