MCPcopy Create free account
hub / github.com/devld/go-drive / readDriveScriptMeta

Function readDriveScriptMeta

drive/script/script_utils.go:235–252  ·  view source on GitHub ↗
(file string, config common.Config)

Source from the content-addressed store, hash-verified

233}
234
235func readDriveScriptMeta(file string, config common.Config) (DriveScript, error) {
236 scriptsPath, _ := config.GetDir(config.DrivesDir, false)
237 scriptFile, e := os.Open(filepath.Join(scriptsPath, file))
238 if e != nil {
239 return DriveScript{}, e
240 }
241 defer func() {
242 _ = scriptFile.Close()
243 }()
244 r := bufio.NewReader(scriptFile)
245 name := readMetaValue(r, true, file)
246 description := readMetaValue(r, false, "")
247 return DriveScript{
248 Name: strings.TrimSuffix(file, ".js"),
249 DisplayName: name,
250 Description: description,
251 }, nil
252}
253
254var metaPrefixRegexp = regexp.MustCompile(`^\s*//\s*`)
255

Callers 2

ListDriveScriptsFunction · 0.85
initConfigFunction · 0.85

Calls 4

readMetaValueFunction · 0.85
GetDirMethod · 0.80
CloseMethod · 0.65
OpenMethod · 0.45

Tested by

no test coverage detected