 
 argv = require('yargs').argv
 fs = require 'fs-extra'
+path = require 'path'
 plugins = require('gulp-load-plugins')()
 yamljs = require 'yamljs'
 

compileLangHandler = (this_lang, source_path, dest_dir, options) ->
  gulp.src source_path
    .pipe plugins[this_lang.plugin](options)
    .pipe gulp.dest(dest_dir + '/' + this_lang.dest)
compileManifest = (dest_dir, update_fn) ->
  manifest_json = yamljs.load resources_path + '/manifest.yml'
  update_fn manifest_json

  dest_path = dest_dir + '/manifest.json'
  fs.writeJSONSync dest_path, manifest_json
getSourcePath = (this_lang) -> this_lang.source + '/*.' + this_lang.extName
watchLang = (lang_name, dest_dir, options) ->
  this_lang = lang[lang_name]


    manifest_json.version = argv.version

  for file_name in ['font', '_locales', 'license.txt']
    fs.copySync file_name, path.join(compile_path, file_name)
  fs.copySync path.join(resources_path, 'img'), path.join(compile_path, 'img')

gulp.task 'compile-zip', ['compile-main', 'compile-others'], ->
  gulp.src path.join(compile_path, '**')
    .pipe plugins.zip(argv.version + '.zip')
    .pipe gulp.dest('.')

gulp.task 'compile', ['compile-zip'], ->
  rmdirp compile_path # useless after zipped
