How to use the node-titanium-sdk.targetPlatforms function in node-titanium-sdk

To help you get started, we’ve selected a few node-titanium-sdk examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github appcelerator / titanium_mobile / cli / commands / clean.js View on Github external
logger.debug(__('Build log does not exist %s', dir.cyan));
							}
							cli.fireHook('clean.' + platform + '.post', function () {
								cli.fireHook('clean.post', function () {
									next();
								});
							});
						});
					});
				};
			}), done);
		} else if (appc.fs.exists(buildDir)) {
			logger.debug(__('Deleting all platform build directories'));

			// scan platform SDK specific clean hooks
			if (ti.targetPlatforms) {
				ti.targetPlatforms.forEach(function (platform) {
					cli.scanHooks(path.join(__dirname, '..', '..', platform, 'cli', 'hooks'));
				});
			}

			cli.fireHook('clean.pre', function () {
				async.series(fs.readdirSync(buildDir).map(function (dir) {
					return function (next) {
						var file = path.join(buildDir, dir);
						cli.fireHook('clean.' + dir + '.pre', function () {
							logger.debug(__('Deleting %s', file.cyan));
							fs.removeSync(file);
							cli.fireHook('clean.' + dir + '.post', function () {
								next();
							});
						});
github appcelerator / titanium_mobile / cli / commands / build.js View on Github external
order: 2,
							prompt: {
								label: __('Target platform'),
								error: __('Invalid platform'),
								validator: function (platform) {
									if (!platform) {
										throw new Error(__('Invalid platform'));
									} else if (ti.availablePlatforms.indexOf(platform) === -1) {
										throw new Error(__('Invalid platform: %s', platform));
									}
									return true;
								}
							},
							required: true,
							skipValueCheck: true,
							values: ti.targetPlatforms
						},
						'project-dir': {
							abbr: 'd',
							callback: function (projectDir) {
								if (projectDir === '') {
									// no option value was specified
									// set project dir to current directory
									projectDir = conf.options['project-dir'].default;
								}

								projectDir = appc.fs.resolvePath(projectDir);

								// load the tiapp.xml/timodule.xml
								if (fs.existsSync(path.join(projectDir, 'tiapp.xml'))) {
									let tiapp;
									try {
github appcelerator / titanium_mobile / cli / commands / clean.js View on Github external
cli.createHook('clean.config', function (callback) {
			var conf = {
				options: appc.util.mix({
					platform: {
						// this is for backwards compatibility and eventually should be dropped
						hidden: true
					},
					platforms: {
						// note: --platforms is not required for the clean command
						abbr: 'p',
						desc: __('one or more platforms to clean'),
						values: ti.targetPlatforms,
						skipValueCheck: true // we do our own validation
					},
					'project-dir': {
						abbr: 'd',
						callback: function (projectDir) {
							if (projectDir === '') {
								// no option value was specified
								// set project dir to current directory
								projectDir = conf.options['project-dir'].default;
							}

							projectDir = appc.fs.resolvePath(projectDir);

							// load the tiapp.xml/timodule.xml
							if (fs.existsSync(path.join(projectDir, 'tiapp.xml'))) {
								let tiapp;
github appcelerator / titanium_mobile / cli / commands / clean.js View on Github external
}
							cli.fireHook('clean.' + platform + '.post', function () {
								cli.fireHook('clean.post', function () {
									next();
								});
							});
						});
					});
				};
			}), done);
		} else if (appc.fs.exists(buildDir)) {
			logger.debug(__('Deleting all platform build directories'));

			// scan platform SDK specific clean hooks
			if (ti.targetPlatforms) {
				ti.targetPlatforms.forEach(function (platform) {
					cli.scanHooks(path.join(__dirname, '..', '..', platform, 'cli', 'hooks'));
				});
			}

			cli.fireHook('clean.pre', function () {
				async.series(fs.readdirSync(buildDir).map(function (dir) {
					return function (next) {
						var file = path.join(buildDir, dir);
						cli.fireHook('clean.' + dir + '.pre', function () {
							logger.debug(__('Deleting %s', file.cyan));
							fs.removeSync(file);
							cli.fireHook('clean.' + dir + '.post', function () {
								next();
							});
						});
					};
github appcelerator / titanium_mobile / cli / commands / clean.js View on Github external
result(finished);
				} else {
					finished(result);
				}
			});
		};

	} else {
		let platforms = cli.argv.platforms || cli.argv.platform;
		if (platforms) {
			platforms = ti.scrubPlatforms(platforms);

			if (platforms.bad.length) {
				logger.error(__n('Invalid platform: %%s', 'Invalid platforms: %%s', platforms.bad.length, platforms.bad.join(', ')) + '\n');
				logger.log(__('Available platforms for SDK version %s:', ti.manifest.sdkVersion) + '\n');
				ti.targetPlatforms.forEach(function (p) {
					logger.log('    ' + p.cyan);
				});
				logger.log();
				process.exit(1);
			}

			cli.argv.platforms = platforms.scrubbed;
		} else {
			cli.argv.platforms = null;
		}

		ti.validateProjectDir(logger, cli, cli.argv, 'project-dir');

		return function (finished) {
			ti.loadPlugins(logger, config, cli, cli.argv['project-dir'], function () {
				finished();