@microsoft/windows-admin-center-sdk
Version:
Microsoft - Windows Admin Center Shell
1 lines • 1.78 kB
Source Map (JSON)
{"version":3,"sources":["../../../packages/tools/gulp-merge-json-in-folders/index.ts"],"names":[],"mappings":"","file":"index.d.ts","sourcesContent":["'use strict';\r\n\r\nimport log from 'fancy-log';\r\nimport pluginError from 'plugin-error';\r\nimport through2 from 'through2';\r\nimport * as util from '../utilities';\r\nimport * as jsonMerge from './json-merge';\r\n\r\nconst PLUGIN_NAME = 'gulp-merge-json-in-folders';\r\n\r\ninterface Options {\r\n /**\r\n * source path of current folder for 'strings.json'\r\n */\r\n src: string;\r\n}\r\n\r\nfunction gulpMergeJsonInFolders(options: Options) {\r\n // override options settings if not specified.\r\n options = Object.assign({ src: './src/assets/strings' }, options || {});\r\n\r\n const externalSources: string[] = [];\r\n\r\n return through2.obj(\r\n /**\r\n * Transform\r\n */\r\n function (file, encoding, callback) {\r\n if (file.isDirectory()) {\r\n externalSources.push(file.path);\r\n }\r\n\r\n callback();\r\n },\r\n\r\n /**\r\n * Flush\r\n */\r\n function (callback) {\r\n try {\r\n const merge = new jsonMerge.JsonMerge();\r\n const files = merge.mergeJsonInFolders(options.src, externalSources);\r\n\r\n files.forEach(file => this.push(file));\r\n } catch (e) {\r\n const error = (!e.plugin || (e.plugin !== PLUGIN_NAME)) ?\r\n util.extendError(new pluginError({ plugin: PLUGIN_NAME, message: e.message }), e) : e;\r\n log.error(error);\r\n }\r\n\r\n callback();\r\n });\r\n}\r\n\r\nmodule.exports = gulpMergeJsonInFolders;\r\n"]}