49 lines
1.6 KiB
TypeScript
49 lines
1.6 KiB
TypeScript
import * as path from 'path'
|
|
import { contentTasks, ICompileOptions, ICompileTaskOptions } from './compile'
|
|
import { option } from '../library'
|
|
import { logger } from '../src/'
|
|
import {
|
|
I18N_SOURCE_LANGUAGE,
|
|
NEWSLETTER_COMPILE_CACHE,
|
|
NEWSLETTER_DEFAULT_ENV,
|
|
NEWSLETTER_LOG_LEVEL} from './config'
|
|
|
|
export const newsletterTasks = (
|
|
grunt,
|
|
taskPrefix = 'newsletter',
|
|
root,
|
|
template,
|
|
src,
|
|
dst,
|
|
taskOptions: ICompileTaskOptions = {},
|
|
compilerOptions: ICompileOptions = {}
|
|
) => {
|
|
|
|
logger.info(`Registering newsletter tasks for ${taskPrefix}`)
|
|
const env = option('env', {}, grunt, NEWSLETTER_DEFAULT_ENV)
|
|
const newsletter_tasks = contentTasks(grunt,
|
|
{
|
|
sourceLanguage: I18N_SOURCE_LANGUAGE,
|
|
src: [path.join(root, src)],
|
|
taskPrefix,
|
|
...taskOptions
|
|
},
|
|
{
|
|
cache: option('cache', {}, grunt, NEWSLETTER_COMPILE_CACHE),
|
|
root,
|
|
env,
|
|
logLevel: option('logLevel', {}, grunt, NEWSLETTER_LOG_LEVEL),
|
|
output: dst,
|
|
template:path.join(root, template),
|
|
variables: {
|
|
env,
|
|
prefix: env,
|
|
root,
|
|
targetLanguage: I18N_SOURCE_LANGUAGE,
|
|
sourceLanguage: I18N_SOURCE_LANGUAGE
|
|
},
|
|
...compilerOptions
|
|
})
|
|
grunt.registerTask(taskPrefix, Object.keys(newsletter_tasks).map((lang: any) => newsletter_tasks[lang].taskName))
|
|
return newsletter_tasks
|
|
} |