Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CocoaPods: support 2 optional arguments #3396

Merged
merged 1 commit into from
Jan 16, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,14 @@
"loc.helpMarkDown": "[More Information](https://go.microsoft.com/fwlink/?LinkID=613745)",
"loc.description": "CocoaPods is a dependency manager for Swift and Objective-C Cocoa projects. This task runs 'pod install'.",
"loc.instanceNameFormat": "pod install",
"loc.group.displayName.advanced": "Advanced",
"loc.input.label.cwd": "Working Directory",
"loc.input.help.cwd": "Specify the working directory in which to execute this step. If left empty, the repository directory will be used.",
"loc.input.label.forceRepoUpdate": "Force Repo Update",
"loc.input.help.forceRepoUpdate": "Selecting this option will force running 'pod repo update' before install.",
"loc.input.label.projectDirectory": "Project Directory",
"loc.input.help.projectDirectory": "Optionally specify the path to the root of the project directory. If left empty, the project specified in the Podfile will be used. If no project is specified, then a search for an Xcode project will be made. If more than one Xcode project is found, an error will occur.",
"loc.messages.PodReturnCode": "The 'pod' command exited with return code: %d",
"loc.messages.PodFailed": "The 'pod' command failed with error: %s",
"loc.messages.CocoaPodsNotFound": "The 'pod' command was not found. Please install CocoaPods on the build machine (https://cocoapods.org/)."
"loc.messages.CocoaPodsNotFound": "The 'pod' command was not found. Please install CocoaPods on the agent machine (https://cocoapods.org/)."
}
22 changes: 19 additions & 3 deletions Tasks/CocoaPods/cocoapods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ import path = require('path');
import tl = require('vsts-task-lib/task');
import trm = require('vsts-task-lib/toolrunner');

// The CocoaPods install command is documented here:
// https://guides.cocoapods.org/terminal/commands.html#pod_install

async function run() {
try {
// Set path to resource strings
Expand All @@ -20,13 +23,26 @@ async function run() {
throw new Error(tl.loc('CocoaPodsNotFound'));
}

// Run 'pod install'
// Prepare to run 'pod install'
var pod: trm.ToolRunner = tl.tool(podPath);
pod.arg('install');

// Force updating the pod repo before install?
if (tl.getBoolInput('forceRepoUpdate', true)) {
pod.arg('--repo-update');
}

// Explicitly specify a project directory?
var projectDirectory: string = tl.getPathInput('projectDirectory', false, true);
if (projectDirectory) {
pod.arg('--project-directory=' + projectDirectory);
}

// Execute
var returnCode: number = await pod.exec();

// Get the result code and set the task result accordingly
var code: number = await pod.exec();
tl.setResult(tl.TaskResult.Succeeded, tl.loc('PodReturnCode', code));
tl.setResult(tl.TaskResult.Succeeded, tl.loc('PodReturnCode', returnCode));
}
catch(err) {
// Report failure
Expand Down
31 changes: 28 additions & 3 deletions Tasks/CocoaPods/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,16 @@
"author": "Microsoft Corporation",
"version": {
"Major": 0,
"Minor": 1,
"Patch": 20
"Minor": 112,
"Patch": 0
},
"groups": [
{
"name": "advanced",
"displayName": "Advanced",
"isExpanded": true
}
],
"instanceNameFormat": "pod install",
"inputs": [
{
Expand All @@ -27,6 +34,24 @@
"defaultValue": "",
"required": false,
"helpMarkDown": "Specify the working directory in which to execute this step. If left empty, the repository directory will be used."
},
{
"name": "forceRepoUpdate",
"type": "boolean",
"label": "Force Repo Update",
"defaultValue": false,
"required": true,
"helpMarkDown": "Selecting this option will force running 'pod repo update' before install.",
"groupName": "advanced"
},
{
"name": "projectDirectory",
"type": "filePath",
"label": "Project Directory",
"defaultValue": "",
"required": false,
"helpMarkDown": "Optionally specify the path to the root of the project directory. If left empty, the project specified in the Podfile will be used. If no project is specified, then a search for an Xcode project will be made. If more than one Xcode project is found, an error will occur.",
"groupName": "advanced"
}
],
"execution": {
Expand All @@ -38,6 +63,6 @@
"messages": {
"PodReturnCode": "The 'pod' command exited with return code: %d",
"PodFailed": "The 'pod' command failed with error: %s",
"CocoaPodsNotFound": "The 'pod' command was not found. Please install CocoaPods on the build machine (https://cocoapods.org/)."
"CocoaPodsNotFound": "The 'pod' command was not found. Please install CocoaPods on the agent machine (https://cocoapods.org/)."
}
}
29 changes: 27 additions & 2 deletions Tasks/CocoaPods/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,16 @@
"author": "Microsoft Corporation",
"version": {
"Major": 0,
"Minor": 1,
"Patch": 20
"Minor": 112,
"Patch": 0
},
"groups": [
{
"name": "advanced",
"displayName": "ms-resource:loc.group.displayName.advanced",
"isExpanded": true
}
],
"instanceNameFormat": "ms-resource:loc.instanceNameFormat",
"inputs": [
{
Expand All @@ -27,6 +34,24 @@
"defaultValue": "",
"required": false,
"helpMarkDown": "ms-resource:loc.input.help.cwd"
},
{
"name": "forceRepoUpdate",
"type": "boolean",
"label": "ms-resource:loc.input.label.forceRepoUpdate",
"defaultValue": false,
"required": true,
"helpMarkDown": "ms-resource:loc.input.help.forceRepoUpdate",
"groupName": "advanced"
},
{
"name": "projectDirectory",
"type": "filePath",
"label": "ms-resource:loc.input.label.projectDirectory",
"defaultValue": "",
"required": false,
"helpMarkDown": "ms-resource:loc.input.help.projectDirectory",
"groupName": "advanced"
}
],
"execution": {
Expand Down