MCPcopy Create free account
hub / github.com/ccxt/ccxt / saveCommand

Function saveCommand

cli/ts/cache.ts:116–139  ·  view source on GitHub ↗

* * @param command

(cm: string[])

Source from the content-addressed store, hash-verified

114 * @param command
115 */
116function saveCommand (cm: string[]) {
117 const commands = cm.slice (2);
118 const command = commands.join (' ');
119 const cachePath = getCacheDirectory ();
120 const historyPath = path.join (cachePath, 'history');
121 if (!fs.existsSync (historyPath)) {
122 try {
123 fs.mkdirSync (historyPath, {
124 'recursive': true,
125 });
126 } catch (e) {
127 log.red ('Error creating cache directory', cachePath);
128 }
129 }
130 const historyFile = path.join (historyPath, 'commands.json');
131 let list: any[] = [];
132 if (!fs.existsSync (historyFile)) {
133 fs.writeFileSync (historyFile, JSON.stringify (list, null, 2));
134 } else {
135 list = JSON.parse (fs.readFileSync (historyFile).toString ()) || [];
136 }
137 list.push (command);
138 fs.writeFileSync (historyFile, JSON.stringify (list, null, 2));
139}
140
141function changeConfigPath (newPath: string) {
142 log ('The config file now will be loaded from: ', newPath);

Callers 1

cli.tsFile · 0.85

Calls 5

getCacheDirectoryFunction · 0.85
pushMethod · 0.80
sliceMethod · 0.45
parseMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…