Script class

Used to manage a DCli script.

This class is primarily for internal use.

We expose Script as it permits some self discovery of the script you are currently running.

Constructors

Script.fromFile(String scriptPathTo, {DartProject? project})
Creates a script object from a scriptArg passed to a command.

Properties

basename String
The scriptname without its '.dart' extension.
no setter
doctor → void
used by the 'doctor' command to prints the details for this project.
no setter
exeName String
Returns the platform dependant name of the compiled script's exe name. On Linux and OSX this is just the basename (script name without the extension) on Windows this is the 'basename.exe'.
no setter
hashCode int
The hash code for this object.
no setterinherited
isCompiled bool
True if the script is compiled.
no setter
isInstalled bool
Checks if the Script has been compiled and installed into the ~/.dcli/bin path
no setter
isPubGlobalActivated bool
True if the script has been installed via 'dart pub global active' and as such is running from the pub cache.
no setter
isReadyToRun bool
True if the script has been pre-compiled via a pub get.
no setter
pathToExe String
Returns the path to the executable if it was to be compiled into its local directory (the default action of compile).
no setter
pathToInstalledExe String
Returns the path that the script would be installed to if compiled with install = true.
no setter
pathToProjectRoot String
Determines the script project root. The project root is defined as the directory which contains the scripts 'pubspec.yaml' file.
no setter
pathToPubSpec String
Returns the path to a scripts pubspec.yaml. The pubspec.yaml is located in the project's root directory.
no setter
pathToScript String
path to the this script.
no setter
pathToScriptDirectory String
the absolute path to the directory the script lives in
no setter
project DartProject
the project for this scrtipt.
no setter
pubsecNameKey String
the name of the script without its extension. this is used for the 'name' key in the pubspec.
no setter
pubSpec PubSpec
reads and returns the project's virtual pubspec and returns it.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
scriptname String
The filename of the script including the extension. If you are running in a compiled script then scriptname won't have a '.dart' extension. In a compiled script the extension generally depends on the OS but it could in theory be anything (except for .dart). Common extensions are .exe for windows and no extension for Linux and OSx.
no setter

Methods

compile({bool install = false, bool overwrite = false}) → void
Compiles this script and optionally installs it to ~/.dcli/bin
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
run(List<String> args) int
Runs the script passing in the given args
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Properties

current Script
Returns the instance of the currently running script.
no setter

Static Methods

sansRoot(String path) String
Strips the root prefix of a path so we can use it as part of the virtual projects path. For linux this just removes any leading / For windows this removes c:\
validate(String scriptPath) → void
validate that the passed arguments points to a valid script