cordova-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Tobias Jamin" <t.ja...@jamin-tannert.de>
Subject Contribution: <lib-file> support for WP7 and WP8
Date Thu, 20 Mar 2014 11:56:06 GMT
Hi Cordova devs,

while writing my first cordova plugin for Windows Phone I noticed the
missing support for <lib-file> for the WP7/WP8 Platforms. The solution is so
damn easy and I would be glad if you take my solution into the cordova code.
The implementation for <lib-file> for WP is very similar to the
implementation of <source-file>. The only difference is the invocation of
addReference instead of addSourceFile (and removeReference instead of
removeSourceFile).

FILE:
plugman\src\platforms\wp8.js

OLD CODE:
    "lib-file": {
        install:function(source_el, plugin_dir, project_dir, plugin_id) {
            require('../../plugman').emit('verbose', 'lib-file.install is
not supported for wp8');
        },
        uninstall:function(source_el, project_dir, plugin_id) {
            require('../../plugman').emit('verbose', 'lib-file.uninstall is
not supported for wp8');
        }
    }

NEW CODE:
    "lib-file": {
        install:function(lib_el, plugin_dir, project_dir, plugin_id,
project_file) {
            var dest = path.join('Plugins', plugin_id,
lib_el.attrib['target-dir'] ? lib_el.attrib['target-dir'] : '',
path.basename(lib_el.attrib['src']));
            var target_path = common.resolveTargetPath(project_dir, dest);
            if (fs.existsSync(target_path)) throw new Error('"' +
target_path + '" already exists!');
            common.copyFile(plugin_dir, lib_el.attrib['src'], project_dir,
dest);
            // add reference to this file to csproj.
            project_file.addReference(dest);
        },
        uninstall:function(lib_el, project_dir, plugin_id, project_file) {
            var dest = path.join('Plugins', plugin_id,
lib_el.attrib['target-dir'] ? lib_el.attrib['target-dir'] : '',
path.basename(lib_el.attrib['src']));
            common.removeFile(project_dir, dest);
            // remove reference to this file from csproj.
            project_file.removeReference(dest);
        }
    }

The implementation for WP7 is exactly the same as for WP8.

Greetings from Germany,

Tobias Jamin



Mime
View raw message