MCPcopy Index your code
hub / github.com/loopbackio/loopback-next / copyFile

Method copyFile

packages/testlab/src/test-sandbox.ts:137–158  ·  view source on GitHub ↗

* Copies a file from src to the TestSandbox. If copying a `.js` file which * has an accompanying `.js.map` file in the src file location, the dest file * will have its sourceMappingURL updated to point to the original file as * an absolute path so you don't need to copy the map file. *

(
    src: string,
    dest?: string,
    transform?: (content: string) => string,
  )

Source from the content-addressed store, hash-verified

135 * @param transform - Optional. A function to transform the file content.
136 */
137 async copyFile(
138 src: string,
139 dest?: string,
140 transform?: (content: string) => string,
141 ): Promise<void> {
142 dest = dest
143 ? resolve(this.path, dest)
144 : resolve(this.path, parse(src).base);
145
146 if (transform == null) {
147 await copy(src, dest);
148 } else {
149 let content = await readFile(src, 'utf-8');
150 content = transform(content);
151 await outputFile(dest, content, {encoding: 'utf-8'});
152 }
153
154 if (parse(src).ext === '.js' && (await pathExists(src + '.map'))) {
155 const srcMap = src + '.map';
156 await appendFile(dest, `\n//# sourceMappingURL=${srcMap}`);
157 }
158 }
159
160 /**
161 * Creates a new file and writes the given data serialized as JSON.

Callers 15

getAppFunction · 0.80
getAppFunction · 0.80
buildAppWithInterceptorsFunction · 0.80
getAppFunction · 0.80
getAppFunction · 0.80
getAppFunction · 0.80
getAppFunction · 0.80
setupSandboxFunction · 0.80

Calls 1

resolveFunction · 0.50

Tested by 14

getAppFunction · 0.64
getAppFunction · 0.64
buildAppWithInterceptorsFunction · 0.64
getAppFunction · 0.64
getAppFunction · 0.64
getAppFunction · 0.64
getAppFunction · 0.64
setupSandboxFunction · 0.64
getAppFunction · 0.64
getAppFunction · 0.64
getAppFunction · 0.64
getAppFunction · 0.64