Skip to content

Commit

Permalink
fix(cordova): handle plugin.xml asset tag (#2728)
Browse files Browse the repository at this point in the history
  • Loading branch information
jcesarmobile authored Apr 8, 2020
1 parent fefa4b9 commit 8e1abfe
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
7 changes: 6 additions & 1 deletion cli/src/cordova.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Config } from './config';
import { Plugin, PluginType, getJSModules, getPlatformElement, getPluginPlatform, getPluginType, getPlugins, printPlugins } from './plugin';
import { Plugin, PluginType, getAssets, getJSModules, getPlatformElement, getPluginPlatform, getPluginType, getPlugins, printPlugins } from './plugin';
import { copySync, ensureDirSync, readFileAsync, removeSync, writeFileAsync } from './util/fs';
import { basename, extname, join, resolve } from 'path';
import { buildXmlElement, installDeps, log, logError, logFatal, logInfo, logWarn, parseXML, readXML, resolveNode, writeXML } from './common';
Expand Down Expand Up @@ -115,6 +115,11 @@ export async function copyPluginsJS(config: Config, cordovaPlugins: Plugin[], pl
data = data.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script\s*>/gi, '');
await writeFileAsync(filePath, data, 'utf8');
}));
const assets = getAssets(p, platform);
assets.map((asset: any) => {
const filePath = join(webDir, asset.$.target);
copySync(join(p.rootPath, asset.$.src), filePath);
});
}));
writeFileAsync(cordovaPluginsJSFile, generateCordovaPluginsJSFile(config, cordovaPlugins, platform));
}
Expand Down
7 changes: 7 additions & 0 deletions cli/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,13 @@ export function getJSModules(p: Plugin, platform: string) {
return getAllElements(p, platform, 'js-module');
}

/**
* Get each asset tag for the given plugin
*/
export function getAssets(p: Plugin, platform: string) {
return getAllElements(p, platform, 'asset');
}

export function getFilePath(config: Config, plugin: Plugin, path: string) {
if (path.startsWith('node_modules')) {
let pathSegments = path.split('/').slice(1);
Expand Down

0 comments on commit 8e1abfe

Please sign in to comment.