put-filepath-as-comment

1.0.1 • Public • Published

put-filepath-as-comment

CircleCI code style: prettier semantic-release: angular

put-filepath-as-comment is a simple npm module that helps you quickly and easily add file paths as comments to your code. It is particularly useful to communicate with ChatGPT.

Usage

To add a file path as a comment, run the following command:

npx put-filepath-as-comment <file path>

For example:

npx put-filepath-as-comment ./tmp/testdata/src

End-to-End Testing

import { execSync } from 'child_process';
import { mkdirSync, readFileSync, rmdirSync, writeFileSync } from 'fs-extra';

describe('commander program', () => {
  it('should output file contents', () => {
    rmdirSync('./tmp/testdata', { recursive: true });
    mkdirSync('./tmp/testdata/src/domain/entities', { recursive: true });
    writeFileSync(
      './tmp/testdata/src/domain/entities/Group.ts',
      `export class Group {
  id: string
  name: string
}`,
    );
    const expectedContent = `// tmp/testdata/src/domain/entities/Group.ts
export class Group {
  id: string
  name: string
}`;

    execSync(
      'npx ts-node ./src/adapter/entry-points/cli/index.ts ./tmp/testdata/src',
    );
    const contents = readFileSync(
      './tmp/testdata/src/domain/entities/Group.ts',
      'utf-8',
    );
    expect(contents).toBe(expectedContent);

    execSync(
      'npx ts-node ./src/adapter/entry-points/cli/index.ts ./tmp/testdata/src',
    );
    const contentsSecondTime = readFileSync(
      './tmp/testdata/src/domain/entities/Group.ts',
      'utf-8',
    );
    expect(contentsSecondTime).toBe(expectedContent);
  });
});

This example demonstrates how put-filepath-as-comment can be used to add a file path comment to the file.

Contributing

Contributions are welcome! Please read the CONTRIBUTING.md file for guidelines on how to contribute to this project.

License

This project is licensed under the MIT License. See the LICENSE file for details.

/put-filepath-as-comment/

    Package Sidebar

    Install

    npm i put-filepath-as-comment

    Weekly Downloads

    2

    Version

    1.0.1

    License

    ISC

    Unpacked Size

    28.2 kB

    Total Files

    30

    Last publish

    Collaborators

    • hiromi