Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions dist/fs.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ export declare function forceRemove(pth: PathLike): Promise<void>;
*/
export declare function isEmptyDir(dir: PathLike): Promise<boolean>;
/**
* writeSecureFile writes a file to disk with 0640 permissions and locks the
* writeSecureFile writes a file to disk with 0600 permissions and locks the
* file during writing.
*
* @param outputPath Path in which to create the secure file.
* @param data Data to write to file.
* @param options additional options to pass to writeFile. The default options
* are permissions of 0640, write-exclusive, and flush-on-success.
* are permissions of 0600, write-exclusive, and flush-on-success.
*
* @returns Path to written file.
*/
Expand Down
6 changes: 3 additions & 3 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/fs/functions/writeSecureFile.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

Defined in: [fs.ts:68](https://github.com/google-github-actions/actions-utils/blob/main/src/fs.ts#L68)

writeSecureFile writes a file to disk with 0640 permissions and locks the
writeSecureFile writes a file to disk with 0600 permissions and locks the
file during writing.

## Type Parameters
Expand Down Expand Up @@ -38,7 +38,7 @@ Data to write to file.
`ObjectEncodingOptions` & `object`

additional options to pass to writeFile. The default options
are permissions of 0640, write-exclusive, and flush-on-success.
are permissions of 0600, write-exclusive, and flush-on-success.

## Returns

Expand Down
6 changes: 3 additions & 3 deletions src/fs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,13 @@ export async function isEmptyDir(dir: PathLike): Promise<boolean> {
}

/**
* writeSecureFile writes a file to disk with 0640 permissions and locks the
* writeSecureFile writes a file to disk with 0600 permissions and locks the
* file during writing.
*
* @param outputPath Path in which to create the secure file.
* @param data Data to write to file.
* @param options additional options to pass to writeFile. The default options
* are permissions of 0640, write-exclusive, and flush-on-success.
* are permissions of 0600, write-exclusive, and flush-on-success.
*
* @returns Path to written file.
*/
Expand All @@ -74,7 +74,7 @@ export async function writeSecureFile<T extends PathLike>(
flush?: boolean;
},
): Promise<T> {
const opts = Object.assign({}, { mode: 0o640, flag: 'wx', flush: true }, options);
const opts = Object.assign({}, { mode: 0o600, flag: 'wx', flush: true }, options);
await fs.writeFile(outputPath, data, opts);
return outputPath;
}
6 changes: 3 additions & 3 deletions tests/fs.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,14 @@ describe('fs', { concurrency: true }, async () => {

if (process.platform !== 'win32') {
const stats = await fs.stat(filepath);
assert.deepStrictEqual(stats.mode.toString(8), '100640');
assert.deepStrictEqual(stats.mode.toString(8), '100600');
}
});

await suite.test('writes a file with custom options', async () => {
const filepath = randomFilepath();
const result = await writeSecureFile(filepath, 'my data', {
mode: 0o600,
mode: 0o700,
encoding: 'utf8',
});
assert.deepStrictEqual(filepath, result);
Expand All @@ -102,7 +102,7 @@ describe('fs', { concurrency: true }, async () => {

if (process.platform !== 'win32') {
const stats = await fs.stat(filepath);
assert.deepStrictEqual(stats.mode.toString(8), '100600');
assert.deepStrictEqual(stats.mode.toString(8), '100700');
}
});
});
Expand Down