Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
"--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) {
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 : '/'))
}
});
});
function resolvePathToModule(_moduleName: string, _relativeTo: string): string | undefined {
// resolve the module relative to the document. We can't use `require` here as the code is webpacked.
const documentFolder = dirname(URI.parse(_relativeTo).fsPath);
const packPath = join(documentFolder, 'node_modules', _moduleName, 'package.json');
if (existsSync(packPath)) {
return URI.file(packPath).toString();
}
return undefined;
}
let stat = await statAsync(filepath)
if (stat && !opts.overwrite && !opts.ignoreIfExists) {
this.showMessage(`${filepath} already exists!`, 'error')
return
}
if (!stat || opts.overwrite) {
// directory
if (filepath.endsWith('/')) {
try {
if (filepath.startsWith('~')) filepath = filepath.replace(/^~/, os.homedir())
await mkdirp(filepath)
} catch (e) {
this.showMessage(`Can't create ${filepath}: ${e.message}`, 'error')
}
} else {
let uri = URI.file(filepath).toString()
let doc = this.getDocument(uri)
if (doc) return
let encoding = await this.getFileEncoding()
fs.writeFileSync(filepath, '', encoding || '')
await this.loadFile(uri)
}
}
}
scannedMeta!.rawAst.walkDecls(word, decl => {
// Variable definition
if (
decl.parent.type === 'rule' &&
decl.parent.selector === ':vars' &&
!!decl.source &&
!!decl.source.start
) {
refs.push({
uri: URI.file(scannedMeta.source).toString(),
range: {
start: {
line: decl.source.start!.line - 1,
character: decl.source.start!.column - 1
},
end: {
line: decl.source.start!.line - 1,
character: decl.source.start!.column + word.length - 1
}
}
});
}
});
scannedMeta!.rawAst.walkDecls(decl => {
export function createMeta(src: string, path: string) {
let meta: StylableMeta;
const fakes: postcss.Rule[] = [];
try {
const ast: postcss.Root = safeParse(src, { from: URI.file(path).fsPath });
if (ast.nodes) {
for (const node of ast.nodes) {
if (node.type === 'decl') {
const r = postcss.rule({ selector: node.prop + ':' + node.value });
r.source = node.source;
node.replaceWith(r);
fakes.push(r);
}
}
}
if (ast.raws.after && ast.raws.after.trim()) {
const r = postcss.rule({ selector: ast.raws.after.trim() });
ast.append(r);
fakes.push(r);
}
let stat = await statAsync(filepath.replace(/\/$/, ''))
let isDir = stat && stat.isDirectory() || filepath.endsWith('/')
if (!stat && !ignoreIfNotExists) {
this.showMessage(`${filepath} not exists`, 'error')
return
}
if (stat == null) return
if (isDir && !recursive) {
this.showMessage(`Can't remove directory, recursive not set`, 'error')
return
}
try {
let method = isDir ? 'rmdir' : 'unlink'
await util.promisify(fs[method])(filepath)
if (!isDir) {
let uri = URI.file(filepath).toString()
let doc = this.getDocument(uri)
if (doc) await this.nvim.command(`silent bwipeout ${doc.bufnr}`)
}
} catch (e) {
this.showMessage(`Error on delete ${filepath}: ${e.message}`, 'error')
}
}
function getUriFromRel(rel: string) {
return URI.file(getAbsFromRel(rel)).toString()
}
}
if (this._query !== undefined) {
const similarity = StringUtils.computeCompletionSimilarity(this._query, name);
if (similarity < similarityLimit) {
return;
}
}
const resolvedSymbol = this._evaluator.resolveAliasDeclaration(declaration);
if (!resolvedSymbol) {
return;
}
const location: Location = {
uri: URI.file(this._filePath).toString(),
range: convertRange(declaration.range)
};
const symbolKind = getSymbolKind(name, declaration, this._evaluator);
if (symbolKind === undefined) {
return;
}
const symbolInfo: SymbolInformation = {
name,
kind: symbolKind,
location
};
if (containerName) {
symbolInfo.containerName = containerName;
private async modifyConfiguration(target: ConfigurationTarget, key: string, value?: any): Promise {
let { nvim, workspace } = this
let file = workspace.getConfigFile(target)
if (!file) return
let formattingOptions: FormattingOptions = { tabSize: 2, insertSpaces: true }
let content = fs.readFileSync(file, 'utf8')
value = value == null ? undefined : value
let edits = modify(content, [key], value, { formattingOptions })
content = applyEdits(content, edits)
fs.writeFileSync(file, content, 'utf8')
let doc = workspace.getDocument(URI.file(file).toString())
if (doc) nvim.command('checktime', true)
return
}