Skip to content
This repository was archived by the owner on Feb 2, 2021. It is now read-only.

Commit d5c663a

Browse files
Use sync version of fs.chmod
1 parent 41789ba commit d5c663a

File tree

4 files changed

+12
-15
lines changed

4 files changed

+12
-15
lines changed

declarations.d.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -338,8 +338,13 @@ interface IFileSystem {
338338
string?: string;
339339
}): any;
340340

341-
chmod(path: string, mode: number): IFuture<any>;
342-
chmod(path: string, mode: string): IFuture<any>;
341+
/**
342+
* Changes file mode of the specified file. In case it is a symlink, the original file's mode is modified.
343+
* @param {string} path Filepath to be modified.
344+
* @param {number | string} mode File mode.
345+
* @returns {void}
346+
*/
347+
chmod(path: string, mode: number | string): void;
343348

344349
setCurrentUserAsOwner(path: string, owner: string): IFuture<void>;
345350
enumerateFilesInDirectorySync(directoryPath: string, filterCallback?: (file: string, stat: IFsStats) => boolean, opts?: { enumerateDirectories?: boolean, includeEmptyDirectories?: boolean }): string[];

file-system.ts

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -241,16 +241,8 @@ export class FileSystem implements IFileSystem {
241241
return fs.createWriteStream(path, options);
242242
}
243243

244-
public chmod(path: string, mode: any): IFuture<void> {
245-
let future = new Future<void>();
246-
fs.chmod(path, mode, (err: Error) => {
247-
if (err) {
248-
future.throw(err);
249-
} else {
250-
future.return();
251-
}
252-
});
253-
return future;
244+
public chmod(path: string, mode: any): void {
245+
fs.chmodSync(path, mode);
254246
}
255247

256248
public getFsStats(path: string): fs.Stats {

services/auto-completion-service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ export class AutoCompletionService implements IAutoCompletionService {
220220
let clientExecutableFileName = (this.$staticConfig.CLIENT_NAME_ALIAS || this.$staticConfig.CLIENT_NAME).toLowerCase();
221221
let pathToExecutableFile = path.join(__dirname, `../../../bin/${clientExecutableFileName}.js`);
222222
this.$childProcess.exec(`"${process.argv[0]}" "${pathToExecutableFile}" completion >> "${filePath}"`).wait();
223-
this.$fs.chmod(filePath, "0644").wait();
223+
this.$fs.chmod(filePath, "0644");
224224
}
225225
} catch(err) {
226226
this.$logger.out("Failed to update %s. Auto-completion may not work. ", filePath);

services/cancellation.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class CancellationService implements ICancellationService {
1010
constructor(private $fs: IFileSystem,
1111
private $logger: ILogger) {
1212
this.$fs.createDirectory(CancellationService.killSwitchDir);
13-
this.$fs.chmod(CancellationService.killSwitchDir, "0777").wait();
13+
this.$fs.chmod(CancellationService.killSwitchDir, "0777");
1414
}
1515

1616
public begin(name: string): IFuture<void> {
@@ -21,7 +21,7 @@ class CancellationService implements ICancellationService {
2121
let streamEnd = this.$fs.futureFromEvent(stream, "finish");
2222
stream.end();
2323
streamEnd.wait();
24-
this.$fs.chmod(triggerFile, "0777").wait();
24+
this.$fs.chmod(triggerFile, "0777");
2525
}
2626

2727
this.$logger.trace("Starting watch on killswitch %s", triggerFile);

0 commit comments

Comments
 (0)