How to use vscode-uri - 10 common examples

To help you get started, we’ve selected a few vscode-uri examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github microsoft / vscode-react-native / test / smoke / automation / src / code.ts View on Github external
"--skip-getting-started",
        "--skip-release-notes",
        "--sticky-quickopen",
        "--disable-telemetry",
        "--disable-updates",
        "--disable-crash-reporter",
        `--extensions-dir=${options.extensionsPath}`,
        `--user-data-dir=${options.userDataDir}`,
        "--driver", handle,
    ];

    const env = process.env;

    if (options.remote) {
        // Replace workspace path with URI
        args[0] = `--${options.workspacePath.endsWith(".code-workspace") ? "file" : "folder"}-uri=vscode-remote://test+test/${URI.file(options.workspacePath).path}`;

        if (codePath) {
            // running against a build: copy the test resolver extension
            const testResolverExtPath = path.join(options.extensionsPath, "vscode-test-resolver");
            if (!fs.existsSync(testResolverExtPath)) {
                const orig = path.join(repoPath, "extensions", "vscode-test-resolver");
                await new Promise((c, e) => ncp(orig, testResolverExtPath, err => err ? e(err) : c()));
            }
        }
        args.push("--enable-proposed-api=vscode.vscode-test-resolver");
        const remoteDataDir = `${options.userDataDir}-server`;
        mkdirp.sync(remoteDataDir);
        env["TESTRESOLVER_DATA_FOLDER"] = remoteDataDir;
    }

    if (!codePath) {
github ocaml-lsp / ocaml-language-server / src / bin / server / processes / merlin.ts View on Github external
public sync({ sync: query }: merlin.Sync, id?: LSP.TextDocumentIdentifier): merlin.Response {
    // this.session.connection.console.log(
    //   JSON.stringify({ query, id, priority }),
    // );
    const context: ["auto", string] | undefined = id ? ["auto", URI.parse(id.uri).fsPath] : undefined;
    const request = context ? { context, query } : query;
    return new Promise(resolve => {
      const task = new merlin.Task(request);
      // eslint-disable-next-line @typescript-eslint/no-explicit-any
      const callback: async.AsyncResultArrayCallback<i> = (value: any) =&gt; {
        resolve(null == value ? undefined : value);
      };
      this.queue.push(task, 0, callback);
    });
  }
</i>
github oslabs-beta / snAppy / src / extension.ts View on Github external
return exec('npx webpack --profile --json > compilation-stats.json', {cwd: __dirname}, (err : Error, stdout: string)=>{
              workspace.fs.readFile(URI.file(path.join(__dirname, 'compilation-stats.json')))
                .then(res => {
                return  panel.webview.postMessage({command: 'post', field: res.toString()});
                });
            });
            break;
        case 'export':
          console.log('exporting files');
          workspace.fs.createDirectory((URI.file(workspace.workspaceFolders? workspace.workspaceFolders[0].uri.path + '/snappy': '/')));
          workspace.fs.readFile(URI.file(path.join(__dirname, 'webpack.config.js')))
            .then( res => {
              // console.log('creating file', URI.file(workspace.workspaceFolders? workspace.workspaceFolders[0].uri.path + '/webpack.config.js': '/'));
              workspace.fs.writeFile(URI.file(workspace.workspaceFolders? workspace.workspaceFolders[0].uri.path + '/snappy/webpack.config.js': '/'), res);
            });
          workspace.fs.readFile(URI.file(path.join(__dirname, 'compilation-stats.json')))
            .then( res => {
              // console.log('creating file', URI.file(workspace.workspaceFolders? workspace.workspaceFolders[0].uri.path + '/compilation-stats.json': '/'));
              workspace.fs.writeFile(URI.file(workspace.workspaceFolders? workspace.workspaceFolders[0].uri.path + '/snappy/compilation-stats.json': '/'), res);
            });
          // workspace.fs.copy(URI.file(`${__dirname}/compilation-stats.json`),URI.file(workspace.workspaceFolders? workspace.workspaceFolders[0].uri.path : '/'))
      }
    });
  });
github oslabs-beta / snAppy / nimble / out / extension.js View on Github external
case "config":
                    console.log("getting input and configuring webpack");
                    console.log("message", message.module);
                    moduleState = Object.assign({}, message.module);
                    // let moduleObj = createModule(moduleState.module);
                    // let webpackConfigObject = createWebpackConfig(moduleState.entry, moduleObj);
                    //console.log(JSON.stringify(webpackConfigObject));
                    //converting the object created using function with inputs from front end
                    //Uint8Array.from - will convert object to to Uint8 array so we can write to a file
                    let readUri = "/Users/courtneykwong/Documents/Codesmith/Projects/soloproject/webpack.config.js";
                    /*the webpack.config file need to be in the root directory but can have a different
                    name as long as specified when using the webpack command
                    write the webpack.config.js into out (__dirname) because childprocess is running in dirr name and webpack is being executed in dirname -> if you don't pass in any arguments, it assumes the file iswebpack.config.js and will be looking for it in the same directory; another way: pass in path to th webpack to whatever config you want to use.s
                  */
                    let writeUri = `${__dirname}/webpack.config.js`;
                    vscode_1.workspace.fs.readFile(vscode_uri_1.URI.file(readUri))
                        .then(res => {
                        console.log('read', res);
                        return vscode_1.workspace.fs.writeFile(vscode_uri_1.URI.file(writeUri), res)
                            .then(res => {
                            console.log('write', res);
                            //exec docs: optional parameter that can show err; stdout: shows detail err in the console;
                            return exec('npx webpack', { cwd: __dirname }, (err, stdout) => {
                                console.log('Error in exec: ', err);
                                console.log(stdout);
                            });
                        });
                    });
                //using workspace.writeFile (path, Uint8 array)
                /*write webpackConfigObject to path: __dirname (refers to where the extension is installed)
                                        .then(res => exec('npx webpack --profile --json > compilation-stats.json', {cwd: __dirname});
                                    */
github xsburg / vscode-javascript-booster / server / src / services / codeModService.ts View on Github external
}
                const stat = await fs.lstat(fileName);
                return {
                    isFile: stat.isFile(),
                    fileName
                };
            })
        ))
            .filter(x => x.isFile)
            .map(x => this._parseCodeModFile(x.fileName));
        // user-workspace code mods
        const wsFolders = await connectionService.connection().workspace.getWorkspaceFolders();
        if (wsFolders) {
            const codemodDir = connectionService.getSettings().codemodDir;
            for (let folder of wsFolders) {
                const folderUri = Uri.parse(folder.uri);
                if (folderUri.scheme !== 'file') {
                    continue;
                }

                const dirName = path.join(folderUri.fsPath, codemodDir);
                if (!(await fs.pathExists(dirName))) {
                    continue;
                }

                const names = await fs.readdir(dirName);
                for (let n of names) {
                    const fn = path.join(dirName, n);
                    if ((await fs.stat(fn)).isFile) {
                        codeMods.push(this._parseCodeModFile(fn));
                    }
                }
github Polymer / polymer-analyzer / src / url-loader / fs-url-loader.ts View on Github external
getFilePath(url: ResolvedUrl): Result {
    if (!url.startsWith('file://')) {
      return {successful: false, error: 'Not a local file:// url.'};
    }
    if (!this.canLoad(url)) {
      return {
        successful: false,
        error: `Path is not inside root directory: ${JSON.stringify(this.root)}`
      };
    }
    const path = Uri.parse(url).fsPath;
    return {successful: true, value: path};
  }
github vuejs / vetur / server / src / modes / template / services / htmlDefinition.ts View on Github external
function getTagDefinition(tag: string, range: Range, open: boolean): Definition {
    tag = tag.toLowerCase(); 

    if (vueFileInfo && vueFileInfo.componentInfo.childComponents) {
      for (const cc of vueFileInfo.componentInfo.childComponents) {
        if (tag === cc.name) {
          if (cc.definition) {
            const loc: Location = {
              uri: URI.file(cc.definition.path).toString(),
              // Todo: Resolve actual default export range
              range: Range.create(0, 0, 0, 0)
            };
            return loc;
          }
        }
      }
    }
    return [];
  }
github eclipse-theia / theia / packages / plugin-ext / src / plugin / workspace.ts View on Github external
findFiles(include: theia.GlobPattern, exclude?: theia.GlobPattern | null, maxResults?: number,
        token: CancellationToken = CancellationToken.None): PromiseLike {
        let includePattern: string;
        let includeFolderUri: string | undefined;
        if (include) {
            if (typeof include === 'string') {
                includePattern = include;
            } else {
                includePattern = include.pattern;
                includeFolderUri = URI.file(include.base).toString();
            }
        } else {
            includePattern = '';
        }

        let excludePatternOrDisregardExcludes: string | false;
        if (exclude === undefined) {
            excludePatternOrDisregardExcludes = ''; // default excludes
        } else if (exclude) {
            if (typeof exclude === 'string') {
                excludePatternOrDisregardExcludes = exclude;
            } else {
                excludePatternOrDisregardExcludes = exclude.pattern;
            }
        } else {
            excludePatternOrDisregardExcludes = false; // no excludes
github GameMakerDiscord / gml-tools-langserver / src / startAndShutdown.ts View on Github external
);

                        this.reference.extensionAddExtension(
                            thisFunc.name,
                            ourJSDOC,
                            doNotAutoComplete,
                            Location.create(URI.file(ourPath).toString(), Range.create(0, 0, 0, 0)),
                            yyFile.name,
                            thisFile.filename
                        );
                    }
                    this.reference.extensionRecordSetHash(yyFile.name, thisFile.filename, thisHash);
                } else {
                    // Get our GML File:
                    const fpath = path.join(this.projectDirectory, 'extensions', yyFile.name, thisFile.filename);
                    const thisURI = URI.file(fpath);
                    const extensionFile = await fse.readFile(fpath, 'utf8');

                    // Check our Hash
                    const ourHasher = crypto.createHash('sha1');
                    const thisHash = ourHasher.update(extensionFile).digest('hex');

                    if (thisExtensionCache && thisExtensionCache[thisFile.filename]) {
                        const cachedHash = thisExtensionCache[thisFile.filename].hash;
                        if (cachedHash === thisHash) {
                            for (const thisExtName in this.projectCache.CachedReference.callables.extensions) {
                                if (
                                    this.projectCache.CachedReference.callables.extensions.hasOwnProperty(thisExtName)
                                ) {
                                    const thisExt = this.projectCache.CachedReference.callables.extensions[thisExtName];
                                    this.reference.extensionAddExtension(
                                        thisExtName,
github ocaml-lsp / ocaml-language-server / src / bin / server / virtual / resource.ts View on Github external
if (null == localappdataFile) throw new Error("LOCALAPPDATA must be set in environment to interpret WSL /home");
      // FIXME: compute localappdata earlier and do it only once
      const localappdata = URI.file(localappdataFile).toString(skipEncoding);
      let match: RegExpMatchArray | null = null;
      // rewrite /mnt/…
      if (null != (match = uri.match(/^file:\/\/\/mnt\/([a-zA-Z])\/(.*)$/))) {
        match.shift();
        const drive = match.shift() as string;
        const rest = match.shift() as string;
        return URI.parse(`file:///${drive}:/${rest}`);
      }
      // rewrite /home/…
      if (null != (match = uri.match(/^file:\/\/\/home\/(.+)$/))) {
        match.shift();
        const rest = match.shift() as string;
        return URI.parse(`${localappdata}/lxss/home/${rest}`);
      }
      throw new Error("unreachable");
    };
    switch (this.source) {