2015-04-09 00:04:50 +03:00
|
|
|
asar = require 'asar'
|
|
|
|
fs = require 'fs'
|
|
|
|
path = require 'path'
|
|
|
|
|
|
|
|
module.exports = (grunt) ->
|
2015-04-09 00:30:32 +03:00
|
|
|
{cp, rm} = require('./task-helpers')(grunt)
|
2015-04-09 00:04:50 +03:00
|
|
|
|
|
|
|
grunt.registerTask 'generate-asar', 'Generate asar archive for the app', ->
|
|
|
|
done = @async()
|
|
|
|
|
2015-04-13 20:30:47 +03:00
|
|
|
unpack = [
|
|
|
|
'*.node'
|
2015-04-13 22:39:01 +03:00
|
|
|
'.ctags'
|
2015-04-13 20:30:47 +03:00
|
|
|
'ctags-darwin'
|
|
|
|
'ctags-linux'
|
|
|
|
'ctags-win32.exe'
|
|
|
|
]
|
|
|
|
unpack = "{#{unpack.join(',')}}"
|
|
|
|
|
2015-04-09 00:04:50 +03:00
|
|
|
appDir = grunt.config.get('atom.appDir')
|
|
|
|
unless fs.existsSync(appDir)
|
|
|
|
grunt.log.error 'The app has to be built before generating asar archive.'
|
|
|
|
return done(false)
|
|
|
|
|
2015-04-13 20:30:47 +03:00
|
|
|
asar.createPackageWithOptions appDir, path.resolve(appDir, '..', 'app.asar'), {unpack}, (err) ->
|
2015-04-09 00:04:50 +03:00
|
|
|
return done(err) if err?
|
2015-04-09 00:30:32 +03:00
|
|
|
|
2015-04-09 00:04:50 +03:00
|
|
|
rm appDir
|
2015-04-09 00:30:32 +03:00
|
|
|
fs.renameSync path.resolve(appDir, '..', 'new-app'), appDir
|
2015-04-09 03:39:36 +03:00
|
|
|
|
|
|
|
ctagsFolder = path.join("#{appDir}.asar.unpacked", 'node_modules', 'symbols-view', 'vendor')
|
|
|
|
for ctagsFile in fs.readdirSync(ctagsFolder)
|
|
|
|
fs.chmodSync(path.join(ctagsFolder, ctagsFile), "755")
|
|
|
|
|
2015-04-09 00:04:50 +03:00
|
|
|
done()
|