Class: P4

.exports~ P4

new P4()

Source:

Methods

add(filepath, done) → {object}

Calls p4 add on the filepath passed.
Parameters:
Name Type Description
filepath string The filepath, can be absolute or relative to cwd
done function The done callback
Source:
Returns:
the child process object
Type
object

cd(dir) → {object}

This function changes the cwd property and behaves much like unix cd. It resolves the new path based on the current CWD, and handles absolute paths too. Supports chaining.
Parameters:
Name Type Description
dir string The directory to cd
Source:
Returns:
this
Type
object

edit(filepath, done) → {object}

Calls p4 edit on the filepath passed.
Parameters:
Name Type Description
filepath string The filepath, can be absolute or relative to cwd
done function The done callback
Source:
Returns:
the child process object
Type
object

have(filepath, done) → {object}

Calls `p4 have` on `filepath`. If filepath is not passed, it will call the cb with an error.
Parameters:
Name Type Description
filepath string The filepath
done function The done callback
Source:
Returns:
the child process object
Type
object

login(username, password, done) → {object}

Calls `p4 login`. Important, this happens in the cwd so whatever P4CONFIG is found will be used.
Parameters:
Name Type Description
username string The username
password string The password
done function The done callback
Source:
Returns:
the child process object
Type
object

pwd() → {string}

Returns the cwd.
Source:
Returns:
The current cwd
Type
string

recursiveStatDir(filepath, done) → {object}

Calls `p4 fstat ...`. If filepath is passed, it will first cd to that path.
Parameters:
Name Type Description
filepath string The filepath
done function The done callback
Source:
Returns:
the child process object
Type
object

recursiveSyncDir(filepath, done) → {object}

Calls `p4 sync ...` in `filepath`. If filepath is not passed, calls `p4 sync ...` in cwd.
Parameters:
Name Type Description
filepath string The filepath
done function The done callback
Source:
Returns:
the child process object
Type
object

revert(filepath, done) → {object}

Calls `p4 revert` on `filepath`. If filepath is not passed, it will call the cb with an error.
Parameters:
Name Type Description
filepath string The filepath
done function The done callback
Source:
Returns:
the child process object
Type
object

revertUnchanged(filepath, done) → {object}

Calls p4 revert -a. Ignores filepath arg.
Parameters:
Name Type Description
filepath string The filepath, ignored
done function The done callback
Source:
Returns:
the child process object
Type
object

runCommand(command, args, done) → {object}

Run a command, used internally but public.
Parameters:
Name Type Description
command string The command to run
args array | string The arguments for the command
done function The done callback
Source:
Returns:
the child process object
Type
object

runShellCommand(command, args, done) → {object}

Runs an arbitrary shell command.
Parameters:
Name Type Description
command string The command to run
args array | string The arguments to pass
done function The done callback
Source:
Returns:
the child process object
Type
object

setOpts(opts) → {object}

Set options for the exec context. Supports all optinos supported by child_process.exec. Supports chaining.
Parameters:
Name Type Description
opts object The options object
Source:
Returns:
this
Type
object

smartEdit(filepath, done) → {object}

Calls p4 edit on the filepath. If an error is thrown, calls p4 add on the filepath.
Parameters:
Name Type Description
filepath string The filepath, can be absolute or relative to cwd
done function The done callback
Source:
Returns:
the child process object
Type
object

stat(filepath, done) → {object}

Calls `p4 fstat` on `path.basename(filepath)`. If filepath is not passed, it will call the cb with an error.
Parameters:
Name Type Description
filepath string The filepath
done function The done callback
Source:
Returns:
the child process object
Type
object

statDir(filepath, done) → {object}

Calls p4 fstat *. If filepath is passed, it will first cd to that path.
Parameters:
Name Type Description
filepath string The filepath
done function The done callback
Source:
Returns:
the child process object
Type
object

submit(filepath, desc, done) → {object}

Calls `p4 submit` on `filepath`.
Parameters:
Name Type Description
filepath string The filepath
desc string The changelist description
done function The done callback
Source:
Returns:
the child process object
Type
object

sync(filepath, done) → {object}

Calls `p4 sync` on `filepath`. If filepath is not passed, calls sync in cwd.
Parameters:
Name Type Description
filepath string The filepath
done function The done callback
Source:
Returns:
the child process object
Type
object

syncDir(filepath, done) → {object}

Calls `p4 sync *` in `filepath`. If filepath is not passed, calls `p4 sync *` in cwd.
Parameters:
Name Type Description
filepath string The filepath
done function The done callback
Source:
Returns:
the child process object
Type
object