Last active
March 1, 2016 08:44
-
-
Save hansemannn/83840da6d7cd39ed6e1e to your computer and use it in GitHub Desktop.
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
var fs = require('fs'), | |
wrench = require('wrench'), | |
path = require('path'), | |
walk = require('walk'); | |
exports.cliVersion = ">=5.0.6"; | |
exports.init = function(logger, config, cli) { | |
var files = []; | |
function copyFile(from, to) { | |
var d = path.dirname(to); | |
fs.existsSync(d) || wrench.mkdirSyncRecursive(d); | |
logger.debug('Copying %s => %s', from.cyan, to.cyan); | |
fs.writeFileSync(to, fs.readFileSync(from)); | |
} | |
// Loop through the platform/ios directory | |
var walker = walk.walk(path.join(this.projectDir, 'platform', 'ios'), { followLinks: false }); | |
// Push found files to files array | |
walker.on('file', function(root, stat, next) { | |
files.push(stat.name); | |
next(); | |
}); | |
// Debug number of found platform files | |
walker.on('end', function() { | |
logger.debug('Found %i iOS assets in platform/ios', files.length.cyan); | |
}); | |
// Loop through found files and copy them to the right location | |
cli.on('build.ios.xcodebuild', function () { | |
files.forEach( function( file, index ) { | |
copyFile(path.join(this.projectDir, 'platform', 'ios', file), path.join(this.xcodeAppDir, file)); | |
}); | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment