pax_global_header00006660000000000000000000000064136536545150014527gustar00rootroot0000000000000052 comment=1638b870b68ee6fe781be03bd29fbf5487b83236 replace-ext-2.0.0/000077500000000000000000000000001365365451500137375ustar00rootroot00000000000000replace-ext-2.0.0/.editorconfig000066400000000000000000000003261365365451500164150ustar00rootroot00000000000000# http://editorconfig.org root = true [*] indent_style = space indent_size = 2 charset = utf-8 trim_trailing_whitespace = true insert_final_newline = true end_of_line = lf [*.md] trim_trailing_whitespace = false replace-ext-2.0.0/.eslintignore000066400000000000000000000000461365365451500164420ustar00rootroot00000000000000test/fixtures/ coverage/ .nyc_output/ replace-ext-2.0.0/.eslintrc000066400000000000000000000000301365365451500155540ustar00rootroot00000000000000{ "extends": "gulp" } replace-ext-2.0.0/.gitattributes000066400000000000000000000000161365365451500166270ustar00rootroot00000000000000* text eol=lf replace-ext-2.0.0/.github/000077500000000000000000000000001365365451500152775ustar00rootroot00000000000000replace-ext-2.0.0/.github/SECURITY.md000066400000000000000000000006161365365451500170730ustar00rootroot00000000000000# Security Policy ## Supported Versions | Version | Supported | | ------- | ------------------ | | 2.x.x | :white_check_mark: | | 1.x.x | :white_check_mark: | | < 1.0 | :x: | ## Reporting a Vulnerability To report a security vulnerability, please use the [Tidelift security contact](https://tidelift.com/security). Tidelift will coordinate the fix and disclosure. replace-ext-2.0.0/.github/workflows/000077500000000000000000000000001365365451500173345ustar00rootroot00000000000000replace-ext-2.0.0/.github/workflows/dev.yml000066400000000000000000000035301365365451500206360ustar00rootroot00000000000000name: dev on: pull_request: push: branches: - master env: CI: true jobs: prettier: name: Formatter runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v2 with: # Make sure the actual branch is checked out when running on pull requests ref: ${{ github.head_ref }} - name: Prettier uses: gulpjs/prettier_action@v2.2 with: # Push back to the same branch that was checked out branch: ${{ github.head_ref }} # This part is also where you can pass other options, for example: commit_message: 'Build: Run prettier' prettier_options: '--write .' test: needs: prettier name: Tests for Node ${{ matrix.node }} on ${{ matrix.os }} runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: node: [10, 12, 14] os: [ubuntu-latest, windows-latest, macos-latest] steps: - name: Clone repository uses: actions/checkout@v2 - name: Set Node.js version uses: actions/setup-node@v1 with: node-version: ${{ matrix.node }} - run: node --version - run: npm --version - name: Install npm dependencies run: npm install - name: Run lint run: npm run lint - name: Run tests run: npm test - name: Coveralls uses: coverallsapp/github-action@v1.1.0 with: github-token: ${{ secrets.GITHUB_TOKEN }} flag-name: ${{matrix.os}}-node-${{ matrix.node }} parallel: true coveralls: needs: test name: Finish up runs-on: ubuntu-latest steps: - name: Coveralls Finished uses: coverallsapp/github-action@v1.1.0 with: github-token: ${{ secrets.github_token }} parallel-finished: true replace-ext-2.0.0/.gitignore000066400000000000000000000017101365365451500157260ustar00rootroot00000000000000# Logs logs *.log npm-debug.log* yarn-debug.log* yarn-error.log* # Runtime data pids *.pid *.seed *.pid.lock # Directory for instrumented libs generated by jscoverage/JSCover lib-cov # Coverage directory used by tools like istanbul coverage # nyc test coverage .nyc_output # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) .grunt # Bower dependency directory (https://bower.io/) bower_components # node-waf configuration .lock-wscript # Compiled binary addons (https://nodejs.org/api/addons.html) build/Release # Dependency directories node_modules/ jspm_packages/ # TypeScript v1 declaration files typings/ # Optional npm cache directory .npm # Optional eslint cache .eslintcache # Optional REPL history .node_repl_history # Output of 'npm pack' *.tgz # Yarn Integrity file .yarn-integrity # dotenv environment variables file .env # next.js build output .next # Garbage files .DS_Store # Test results test.xunit replace-ext-2.0.0/.npmrc000066400000000000000000000000231365365451500150520ustar00rootroot00000000000000package-lock=false replace-ext-2.0.0/.prettierignore000066400000000000000000000000271365365451500170010ustar00rootroot00000000000000coverage/ .nyc_output/ replace-ext-2.0.0/LICENSE000066400000000000000000000022211365365451500147410ustar00rootroot00000000000000The MIT License (MIT) Copyright (c) 2014-2020 Blaine Bublitz , Eric Schoffstall and other contributors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. replace-ext-2.0.0/README.md000066400000000000000000000037211365365451500152210ustar00rootroot00000000000000

# replace-ext [![NPM version][npm-image]][npm-url] [![Downloads][downloads-image]][npm-url] [![Build Status][ci-image]][ci-url] [![Coveralls Status][coveralls-image]][coveralls-url] Replaces a file extension with another one. ## Usage ```js var replaceExt = require('replace-ext'); var path = '/some/dir/file.js'; var newPath = replaceExt(path, '.coffee'); console.log(newPath); // /some/dir/file.coffee ``` ## API ### `replaceExt(path, extension)` Replaces the extension from `path` with `extension` and returns the updated path string. Does not replace the extension if `path` is not a string or is empty. ## `replace-ext` for enterprise Available as part of the Tidelift Subscription. The maintainers of `replace-ext` and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. [Learn more.][tidelift-url] ## License MIT [downloads-image]: https://img.shields.io/npm/dm/replace-ext.svg?style=flat-square [npm-url]: https://www.npmjs.com/package/replace-ext [npm-image]: https://img.shields.io/npm/v/replace-ext.svg?style=flat-square [ci-url]: https://github.com/gulpjs/replace-ext/actions?query=workflow:dev [ci-image]: https://img.shields.io/github/workflow/status/gulpjs/replace-ext/dev?style=flat-square [coveralls-url]: https://coveralls.io/r/gulpjs/replace-ext [coveralls-image]: https://img.shields.io/coveralls/gulpjs/replace-ext/master.svg?style=flat-square [tidelift-url]: https://tidelift.com/subscription/pkg/npm-replace-ext?utm_source=npm-replace-ext&utm_medium=referral&utm_campaign=enterprise&utm_term=repo replace-ext-2.0.0/index.js000066400000000000000000000013621365365451500154060ustar00rootroot00000000000000'use strict'; var path = require('path'); function replaceExt(npath, ext) { if (typeof npath !== 'string') { return npath; } if (npath.length === 0) { return npath; } var nFileName = path.basename(npath, path.extname(npath)) + ext; var nFilepath = path.join(path.dirname(npath), nFileName); // Because `path.join` removes the head './' from the given path. // This removal can cause a problem when passing the result to `require` or // `import`. if (startsWithSingleDot(npath)) { return '.' + path.sep + nFilepath; } return nFilepath; } function startsWithSingleDot(fpath) { var first2chars = fpath.slice(0, 2); return first2chars === '.' + path.sep || first2chars === './'; } module.exports = replaceExt; replace-ext-2.0.0/package.json000066400000000000000000000016411365365451500162270ustar00rootroot00000000000000{ "name": "replace-ext", "version": "2.0.0", "description": "Replaces a file extension with another one.", "author": "Gulp Team (http://gulpjs.com/)", "contributors": [ "Eric Schoffstall ", "Blaine Bublitz " ], "repository": "gulpjs/replace-ext", "license": "MIT", "engines": { "node": ">= 10" }, "main": "index.js", "files": [ "LICENSE", "index.js" ], "scripts": { "lint": "eslint .", "pretest": "npm run lint", "test": "nyc mocha --async-only" }, "devDependencies": { "eslint": "^6.8.0", "eslint-config-gulp": "^4.0.0", "expect": "^25.4.0", "mocha": "^7.1.2", "nyc": "^15.0.1" }, "nyc": { "reporter": [ "lcov", "text-summary" ] }, "prettier": { "singleQuote": true }, "keywords": [ "gulp", "extensions", "filepath", "basename" ] } replace-ext-2.0.0/test/000077500000000000000000000000001365365451500147165ustar00rootroot00000000000000replace-ext-2.0.0/test/.eslintrc000066400000000000000000000000351365365451500165400ustar00rootroot00000000000000{ "extends": "gulp/test" } replace-ext-2.0.0/test/main.js000066400000000000000000000057541365365451500162130ustar00rootroot00000000000000'use strict'; var path = require('path'); var os = require('os'); var expect = require('expect'); var replaceExt = require('../'); describe('replace-ext', function () { it('returns a valid replaced extension on long path', function (done) { var fname = path.join(__dirname, './fixtures/test.coffee'); var expected = path.join(__dirname, './fixtures/test.js'); var result = replaceExt(fname, '.js'); expect(result).toEqual(expected); done(); }); it('returns a valid replaced extension on basename', function (done) { var fname = 'test.coffee'; var expected = 'test.js'; var result = replaceExt(fname, '.js'); expect(result).toEqual(expected); done(); }); it('should not return a valid replaced extension on empty string', function (done) { var fname = ''; var expected = ''; var result = replaceExt(fname, '.js'); expect(result).toEqual(expected); done(); }); it('returns a valid removed extension on long path', function (done) { var fname = path.join(__dirname, './fixtures/test.coffee'); var expected = path.join(__dirname, './fixtures/test'); var result = replaceExt(fname, ''); expect(result).toEqual(expected); done(); }); it('returns a valid added extension on long path', function (done) { var fname = path.join(__dirname, './fixtures/test'); var expected = path.join(__dirname, './fixtures/test.js'); var result = replaceExt(fname, '.js'); expect(result).toEqual(expected); done(); }); it('should not replace when 1st arg is not a string (null)', function (done) { var result = replaceExt(null, '.js'); expect(result).toEqual(null); done(); }); it('should not replace when 1st arg is not a string (object)', function (done) { var obj = {}; var result = replaceExt(obj, '.js'); expect(result).toEqual(obj); done(); }); it('Should preserve the first dot of relative dir name.', function (done) { if (os.platform() === 'win32') { expect(replaceExt('a/b/c.js', '.ts')).toEqual('a\\b\\c.ts'); expect(replaceExt('./a/b/c.js', '.ts')).toEqual('.\\a\\b\\c.ts'); expect(replaceExt('../a/b/c.js', '.ts')).toEqual('..\\a\\b\\c.ts'); expect(replaceExt('/a/b/c.js', '.ts')).toEqual('\\a\\b\\c.ts'); expect(replaceExt('C:/a/b/c.js', '.ts')).toEqual('C:\\a\\b\\c.ts'); expect(replaceExt('a\\b\\c.js', '.ts')).toEqual('a\\b\\c.ts'); expect(replaceExt('.\\a\\b\\c.js', '.ts')).toEqual('.\\a\\b\\c.ts'); expect(replaceExt('..\\a\\b\\c.js', '.ts')).toEqual('..\\a\\b\\c.ts'); expect(replaceExt('\\a\\b\\c.js', '.ts')).toEqual('\\a\\b\\c.ts'); expect(replaceExt('C:\\a\\b\\c.js', '.ts')).toEqual('C:\\a\\b\\c.ts'); } else { expect(replaceExt('a/b/c.js', '.ts')).toEqual('a/b/c.ts'); expect(replaceExt('./a/b/c.js', '.ts')).toEqual('./a/b/c.ts'); expect(replaceExt('../a/b/c.js', '.ts')).toEqual('../a/b/c.ts'); expect(replaceExt('/a/b/c.js', '.ts')).toEqual('/a/b/c.ts'); } done(); }); });