{"id":15893829,"url":"https://github.com/chinanf-boy/path-run-explain","last_synced_at":"2026-03-18T17:45:03.104Z","repository":{"id":90548481,"uuid":"134117751","full_name":"chinanf-boy/path-run-explain","owner":"chinanf-boy","description":"explain: path-run 「rewrite And change project Path require|from 更改项目文件-被其他文件导入的所在位置 」","archived":false,"fork":false,"pushed_at":"2018-05-20T03:50:18.000Z","size":3,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-08T08:47:13.445Z","etag":null,"topics":["cli","explain","nodepaths","path-run"],"latest_commit_sha":null,"homepage":null,"language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/chinanf-boy.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"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,"publiccode":null,"codemeta":null}},"created_at":"2018-05-20T03:49:59.000Z","updated_at":"2023-02-13T22:21:54.000Z","dependencies_parsed_at":"2023-07-18T11:00:28.303Z","dependency_job_id":null,"html_url":"https://github.com/chinanf-boy/path-run-explain","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chinanf-boy%2Fpath-run-explain","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chinanf-boy%2Fpath-run-explain/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chinanf-boy%2Fpath-run-explain/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chinanf-boy%2Fpath-run-explain/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chinanf-boy","download_url":"https://codeload.github.com/chinanf-boy/path-run-explain/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246866100,"owners_count":20846496,"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":["cli","explain","nodepaths","path-run"],"created_at":"2024-10-06T08:13:50.682Z","updated_at":"2026-01-12T06:42:15.332Z","avatar_url":"https://github.com/chinanf-boy.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# Path-run\n\n「 更改项目文件-被其他文件导入的所在位置 」\n\n[![explain](http://llever.com/explain.svg)](https://github.com/chinanf-boy/Source-Explain) \u003c\u003c ⬅️ more explain\n    \nExplanation\n\n\u003e \"version\": \"0.0.5\"\n\n[github source](https://github.com/chinanf-boy/Path-run)\n\n[中文](./readme.md) | ~~[english](./readme.en.md)~~\n\n---\n\n作为 项目中的 成员 可能会被其他文件 `require`, 但是当想更改在项目中的位置\n\n那么需要注意的有两点\n\n1. 其他文件导入自身 的路径更改\n\n2. 自身文件的`require`路径更改\n\n所有就有了 `path-run`\n\n\n---\n\n本目录\n\n- [package.json](#package-json)\n- [cli.js 开始](#cli)\n- [require](#require)\n- [meow-cli](#meow-cli)\n- [cli-main](#cli-main)\n\n---\n\n\n### package.json\n\n\n``` js\n\t\"main\": \"./index.js\",\n\t\"bin\": \"cli.js\",\n\n```\n\n从 `cli.js` 开始吧\n\n### cli\n\n\n#### require\n\n``` js\n#!/usr/bin/env node\n(async () =\u003e {\n\t\"use strict\";\n\tconst meow = require(\"meow\");\n\tconst path = require(\"path\");\n\tconst chalk = require(\"chalk\");\n\tconst replace = require('replace-in-file');\n\tconst { pathRun, IsTruePath} =  require('./index.js');\n\n```\n\n#### meow-cli\n\n命令行定义\n\n可以看出只有两个 `一进一出`\n\n``` js\n\tconst cli = meow(`\n\tUsage\n\t  $ path-run [input] [output]\n\n\tOptions\n\t\tinput  要更改的路径\n\t\toutput 变成的路径\n\n\t\tExamples\n        $ path-run './index' './lib/index'\n\n  will change all process.cwd()/* files require Path 'index' =\u003e './lib/index'`);\n\nconst CWD = process.cwd()\n\nif (!cli.input || cli.input.length !== 2) {\n\tconsole.log(cli.help);\n\tprocess.exit(1);\n}\n\nlet In = cli.input[0];\nlet Out = cli.input[1];\n\nlet InPath = path.resolve(CWD, In) // 获得文件绝对值\nlet OutPath = path.resolve(CWD, Out)\n\n```\n\n#### cli-main\n\n``` js\ntry{\n\n\tlet replaceMesaages = await pathRun({InPath, OutPath, cwd:CWD}) // 主要 函数\n\n\tif(replaceMesaages.length) \n\tfor(let i in replaceMesaages){\n\n\t\tlet changes = await replace(replaceMesaages[i]) // 文件替换工具\n\n\t\tchanges.length \u003e 0 \u0026\u0026 (console.log(chalk.green(changes),chalk.blue(\" \u003e\u003e\u003e Done\")))\n\t}\n\n\tif(process.env.RUN_DEBUG){\n\t\tconsole.log(replaceMesaages)\n\t}\n\n\tconsole.log(chalk.yellow(\"All done\"))\n\n}catch(err){\n\tthrow new Error(\"cli\"+err)\n}\n})();\n\n```\n\n- [pathRun](./index.md)\n\n返回 提供给 replace 使用的 数据\n\n- replace\n\n[replace-in-file 更改文件中文本的工具](https://github.com/adamreisnz/replace-in-file) \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchinanf-boy%2Fpath-run-explain","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchinanf-boy%2Fpath-run-explain","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchinanf-boy%2Fpath-run-explain/lists"}