{"id":13630759,"url":"https://github.com/sindresorhus/gulp-changed","last_synced_at":"2025-05-14T15:06:02.817Z","repository":{"id":13327999,"uuid":"16014885","full_name":"sindresorhus/gulp-changed","owner":"sindresorhus","description":"Only pass through changed files","archived":false,"fork":false,"pushed_at":"2024-03-11T16:45:12.000Z","size":73,"stargazers_count":743,"open_issues_count":7,"forks_count":43,"subscribers_count":15,"default_branch":"main","last_synced_at":"2025-05-05T08:03:34.307Z","etag":null,"topics":["gulp-plugin","javascript","nodejs"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sindresorhus.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"license","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null},"funding":{"github":"sindresorhus","open_collective":"sindresorhus","buy_me_a_coffee":"sindresorhus","custom":"https://sindresorhus.com/donate"}},"created_at":"2014-01-17T23:36:38.000Z","updated_at":"2025-02-05T15:38:47.000Z","dependencies_parsed_at":"2024-04-15T02:42:53.447Z","dependency_job_id":"a4311133-a51f-40bf-ac37-a370bfddaedd","html_url":"https://github.com/sindresorhus/gulp-changed","commit_stats":{"total_commits":82,"total_committers":23,"mean_commits":"3.5652173913043477","dds":"0.30487804878048785","last_synced_commit":"aae3ed10a6533464716e5f12dce6b8b1c3907f58"},"previous_names":[],"tags_count":26,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Fgulp-changed","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Fgulp-changed/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Fgulp-changed/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Fgulp-changed/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sindresorhus","download_url":"https://codeload.github.com/sindresorhus/gulp-changed/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252877510,"owners_count":21818388,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["gulp-plugin","javascript","nodejs"],"created_at":"2024-08-01T22:01:58.699Z","updated_at":"2025-05-14T15:06:02.751Z","avatar_url":"https://github.com/sindresorhus.png","language":"JavaScript","readme":"# gulp-changed\n\n\u003e Only pass through changed files\n\nNo more wasting precious time on processing unchanged files.\n\nBy default it's only able to detect whether files in the stream changed. If you require something more advanced like knowing if imports/dependencies changed, create a custom comparator, or use [another plugin](https://github.com/gulpjs/gulp#incremental-builds).\n\n## Install\n\n```sh\nnpm install --save-dev gulp-changed\n```\n\n## Usage\n\n```js\nimport gulp from 'gulp';\nimport changed from 'gulp-changed';\nimport ngAnnotate from 'gulp-ng-annotate'; // Just as an example\n\nconst SOURCE = 'src/*.js';\nconst DESTINATION = 'dist';\n\nexports.default = () =\u003e (\n\tgulp.src(SOURCE)\n\t\t.pipe(changed(DESTINATION))\n\t\t// `ngAnnotate` will only get the files that\n\t\t// changed since the last time it was run\n\t\t.pipe(ngAnnotate())\n\t\t.pipe(gulp.dest(DESTINATION))\n);\n```\n\n## API\n\n### changed(destination, options?)\n\n#### destination\n\nType: `string | Function`\n\nDestination directory. Same as you put into `gulp.dest()`.\n\nThis is needed to be able to compare the current files with the destination files.\n\nCan also be a function returning a destination directory path.\n\n#### options\n\nType: `object`\n\n##### cwd\n\nType: `string`\\\nDefault: `process.cwd()`\n\nWorking directory the folder is relative to.\n\n##### extension\n\nType: `string`\n\nExtension of the destination files.\n\nUseful if it differs from the original, like in the example below:\n\n```js\nexport const jade = () =\u003e (\n\tgulp.src('src/**/*.jade')\n\t\t.pipe(changed('app', {extension: '.html'}))\n\t\t.pipe(jade())\n\t\t.pipe(gulp.dest('app'))\n);\n```\n\n##### hasChanged\n\nType: `Function`\\\nDefault: `compareLastModifiedTime`\n\nFunction that determines whether the source file is different from the destination file.\n\n###### Built-in comparators\n\nNamed imports:\n\n- `compareLastModifiedTime`\n- `compareContents`\n\n###### Example\n\n```js\nimport {compareContents} from 'gulp-changed';\n\nexport const jade = () =\u003e (\n\tgulp.src('src/**/*.jade')\n\t\t.pipe(changed('app', {hasChanged: compareContents}))\n\t\t.pipe(jade())\n\t\t.pipe(gulp.dest('app'))\n);\n```\n\nYou can also specify a custom comparator function, which will receive the following arguments:\n\n- `sourceFile` *([Vinyl file object](https://github.com/wearefractal/vinyl#file))*\n- `destinationPath` *(string)* - The destination for `sourceFile` as an absolute path\n\nThe function is expected to return `sourceFile | Promise\u003csourceFile\u003e` if it passes some comparison or `undefined | Promise\u003cundefined\u003e`. [Examples.](https://github.com/sindresorhus/gulp-changed/blob/4e59a0105c8c10c56f9f8cd153c696e005afa64f/index.js#L7-L28)\n\n##### transformPath\n\nType: `Function`\n\nFunction to transform the path to the destination file. Should return the absolute path to the (renamed) destination file.\n\nUseful if you rename your file later on, like in the below example:\n\n```js\nexport const marked = () =\u003e (\n\tgulp.src('src/content/about.md')\n\t\t.pipe(changed('dist', {\n\t\t\ttransformPath: newPath =\u003e path.join(path.dirname(newPath), path.basename(newPath, '.md'), 'index.html')\n\t\t}))\n\t\t.pipe(marked())\n\t\t.pipe(rename(newPath =\u003e path.join(path.dirname(newPath), path.basename(newPath, '.md'), 'index.html')))\n\t\t.pipe(gulp.dest('dist'))\n);\n```\n\n## In-place change monitoring\n\nIf you're looking to process source files in-place without any build output (formatting, linting, etc), have a look at [gulp-changed-in-place](https://github.com/alexgorbatchev/gulp-changed-in-place).\n","funding_links":["https://github.com/sponsors/sindresorhus","https://opencollective.com/sindresorhus","https://buymeacoffee.com/sindresorhus","https://sindresorhus.com/donate"],"categories":["JavaScript","Plugins","插件"],"sub_categories":["Caching","缓存"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsindresorhus%2Fgulp-changed","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsindresorhus%2Fgulp-changed","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsindresorhus%2Fgulp-changed/lists"}