forked from bluelovers/idea-l10n-zht
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
71a7ac7
commit f0b1b2c
Showing
6 changed files
with
90 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import { readFile } from 'fs-extra'; | ||
import { __file_plugin_dev_meta_xml, __file_plugin_src_meta_xml } from '../const'; | ||
import { PluginXml } from '../util/xml/plugin-xml'; | ||
import { _getVersionDownloadByVersion } from '../util/version-map'; | ||
import { readFileSync } from 'fs'; | ||
|
||
function _handleInput(useSrc: boolean) | ||
{ | ||
useSrc = !!useSrc; | ||
|
||
const file = useSrc ? __file_plugin_src_meta_xml : __file_plugin_dev_meta_xml; | ||
|
||
return { | ||
useSrc, | ||
file, | ||
} | ||
} | ||
|
||
export function _getSourceInfoCore(input: { | ||
useSrc: boolean, | ||
file: string, | ||
content: Buffer | string, | ||
}) | ||
{ | ||
const pluginMeta = new PluginXml(input.content); | ||
|
||
return { | ||
useSrc: !!input.useSrc, | ||
file: input.file, | ||
pluginMeta, | ||
getDownloadURL() | ||
{ | ||
return _getVersionDownloadByVersion(pluginMeta.version) | ||
}, | ||
} | ||
} | ||
|
||
export function getSourceInfoSync(useSrc?: boolean) | ||
{ | ||
const input = _handleInput(useSrc); | ||
|
||
const content = readFileSync(input.file); | ||
|
||
return _getSourceInfoCore({ | ||
...input, | ||
content, | ||
}) | ||
} | ||
|
||
export function getSourceInfo(useSrc?: boolean) | ||
{ | ||
const input = _handleInput(useSrc); | ||
|
||
return readFile(input.file) | ||
.then(content => | ||
{ | ||
return _getSourceInfoCore({ | ||
...input, | ||
content, | ||
}) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,9 @@ | ||
import { join } from 'upath2'; | ||
import { __plugin_dev_raw_dir } from '../lib/const'; | ||
import { __file_plugin_dev_meta_xml } from '../lib/const'; | ||
import { outputFile, readFile } from 'fs-extra'; | ||
import Bluebird from 'bluebird'; | ||
import { updateMeta } from '../lib/meta'; | ||
|
||
const fullpath_new = join(__plugin_dev_raw_dir, 'zh', 'META-INF/plugin.xml'); | ||
|
||
export default Bluebird.resolve(readFile(fullpath_new)) | ||
export default Bluebird.resolve(readFile(__file_plugin_dev_meta_xml)) | ||
.then(buf => updateMeta(buf.toString())) | ||
.then(content_new => outputFile(fullpath_new, content_new)) | ||
.then(content_new => outputFile(__file_plugin_dev_meta_xml, content_new)) | ||
; |