Mailspring/build/tasks/add-nylas-build-resources-task.coffee

40 lines
1.3 KiB
CoffeeScript
Raw Normal View History

2015-12-03 06:45:32 +08:00
fs = require 'fs-plus'
path = require 'path'
module.exports = (grunt) ->
{cp, mkdir, rm} = require('./task-helpers')(grunt)
rootDir = path.resolve(path.join('../', 'src', 'pro'))
2015-12-03 06:45:32 +08:00
copyArcFiles = ->
cp path.join(rootDir, 'arc-N1', '.arcconfig'), '.arcconfig'
cp path.join(rootDir, 'arc-N1', '.arclint'), '.arclint'
cp path.join(rootDir, 'arc-N1', 'arclib'), 'arclib'
copySourceExtensions = ->
cp path.join(rootDir, 'src'), 'src'
linkPlugins = ->
for plugin in fs.readdirSync(path.join(rootDir, 'packages'))
from = path.join(rootDir, 'packages', plugin)
to = path.join(path.resolve('internal_packages'), plugin)
2016-04-26 07:18:23 +08:00
try
if fs.lstatSync(to)
grunt.log.writeln "Removing old symlink at #{to}"
fs.unlinkSync(to)
grunt.log.writeln "Adding '#{plugin}' to internal_packages"
fs.symlinkSync(from, to, 'dir')
2015-12-03 06:45:32 +08:00
desc = 'Adds in proprietary Nylas packages, fonts, and sounds to N1'
grunt.registerTask 'add-nylas-build-resources', desc, ->
canaryFileExists = fs.existsSync(path.join(rootDir, "README.md"))
if not canaryFileExists
grunt.log.writeln "No extra Nylas resources added"
return
else
grunt.log.writeln "Found proprietary Nylas plugins"
copyArcFiles()
copySourceExtensions()
linkPlugins()