Javascript 为什么Cordova项目具有相同的index.js副本?

Javascript 为什么Cordova项目具有相同的index.js副本?,javascript,android,node.js,file,cordova,Javascript,Android,Node.js,File,Cordova,我提供了很多背景信息来帮助你回答这个问题,但是你可以跳到标题“问题”来跳到要点 背景 我对使用Cordova还不熟悉,而且我还不熟悉我想进一步开发的现有Cordova项目。因此,当我查看项目文件时,我不确定以前的开发人员做出了哪些选择,以及Cordova自动做出了哪些选择。我怀疑Cordova生成了很多不是由应用程序开发人员创建的文件,因为在我的例子中,有7900多个文件,包括源代码和自述文件,而应用程序以前(至少据我所知)仅由一个人开发 虽然可以从这个角度提出许多问题,但我想缩小一个具体问题的

我提供了很多背景信息来帮助你回答这个问题,但是你可以跳到标题“问题”来跳到要点

背景 我对使用Cordova还不熟悉,而且我还不熟悉我想进一步开发的现有Cordova项目。因此,当我查看项目文件时,我不确定以前的开发人员做出了哪些选择,以及Cordova自动做出了哪些选择。我怀疑Cordova生成了很多不是由应用程序开发人员创建的文件,因为在我的例子中,有7900多个文件,包括源代码和自述文件,而应用程序以前(至少据我所知)仅由一个人开发

虽然可以从这个角度提出许多问题,但我想缩小一个具体问题的范围,以避免过于宽泛。我注意到路径结构中有许多文件名为
index.js

$ find . -name "index.js"
./platforms/android/app/build/intermediates/assets/debug/www/js/index.js
./platforms/android/app/src/main/assets/www/js/index.js
./platforms/android/cordova/node_modules/balanced-match/index.js
./platforms/android/cordova/node_modules/os-tmpdir/index.js
./platforms/android/cordova/node_modules/concat-map/index.js
./platforms/android/cordova/node_modules/properties-parser/index.js
./platforms/android/cordova/node_modules/elementtree/lib/parsers/index.js
./platforms/android/cordova/node_modules/os-homedir/index.js
./platforms/android/cordova/node_modules/xmlbuilder/lib/index.js
./platforms/android/cordova/node_modules/ansi/examples/beep/index.js
./platforms/android/cordova/node_modules/ansi/examples/progress/index.js
./platforms/android/cordova/node_modules/ansi/examples/clear/index.js
./platforms/android/cordova/node_modules/path-is-absolute/index.js
./platforms/android/cordova/node_modules/brace-expansion/index.js
./platforms/android/cordova/node_modules/sax/test/index.js
./platforms/android/cordova/node_modules/android-versions/index.js
./platforms/android/cordova/node_modules/lodash/index.js
./platforms/android/cordova/node_modules/cordova-registry-mapper/index.js
./www/js/index.js
./node_modules/objectorarray/index.js
./node_modules/es-abstract/index.js
./node_modules/es-abstract/test/index.js
./node_modules/isexe/index.js
./node_modules/balanced-match/index.js
./node_modules/object-keys/index.js
./node_modules/object-keys/test/index.js
./node_modules/has/src/index.js
./node_modules/has/test/index.js
./node_modules/semver/test/index.js
./node_modules/string.prototype.trim/index.js
./node_modules/string.prototype.trim/test/index.js
./node_modules/cordova-plugin-file/src/blackberry10/index.js
./node_modules/jsonfile/index.js
./node_modules/fs-extra/lib/ensure/index.js
./node_modules/fs-extra/lib/remove/index.js
./node_modules/fs-extra/lib/move/index.js
./node_modules/fs-extra/lib/output/index.js
./node_modules/fs-extra/lib/copy-sync/index.js
./node_modules/fs-extra/lib/fs/index.js
./node_modules/fs-extra/lib/empty/index.js
./node_modules/fs-extra/lib/index.js
./node_modules/fs-extra/lib/path-exists/index.js
./node_modules/fs-extra/lib/copy/index.js
./node_modules/fs-extra/lib/move-sync/index.js
./node_modules/fs-extra/lib/json/index.js
./node_modules/fs-extra/lib/mkdirs/index.js
./node_modules/concat-map/index.js
./node_modules/elementtree/lib/parsers/index.js
./node_modules/fs.realpath/index.js
./node_modules/plist/index.js
./node_modules/path-key/index.js
./node_modules/xmlbuilder/lib/index.js
./node_modules/ansi/examples/beep/index.js
./node_modules/ansi/examples/progress/index.js
./node_modules/ansi/examples/clear/index.js
./node_modules/cordova-android/node_modules/balanced-match/index.js
./node_modules/cordova-android/node_modules/os-tmpdir/index.js
./node_modules/cordova-android/node_modules/concat-map/index.js
./node_modules/cordova-android/node_modules/properties-parser/index.js
./node_modules/cordova-android/node_modules/elementtree/lib/parsers/index.js
./node_modules/cordova-android/node_modules/os-homedir/index.js
./node_modules/cordova-android/node_modules/xmlbuilder/lib/index.js
./node_modules/cordova-android/node_modules/ansi/examples/beep/index.js
./node_modules/cordova-android/node_modules/ansi/examples/progress/index.js
./node_modules/cordova-android/node_modules/ansi/examples/clear/index.js
./node_modules/cordova-android/node_modules/path-is-absolute/index.js
./node_modules/cordova-android/node_modules/brace-expansion/index.js
./node_modules/cordova-android/node_modules/sax/test/index.js
./node_modules/cordova-android/node_modules/android-versions/index.js
./node_modules/cordova-android/node_modules/lodash/index.js
./node_modules/cordova-android/node_modules/cordova-registry-mapper/index.js
./node_modules/cordova-android/bin/templates/project/assets/www/js/index.js
./node_modules/for-each/index.js
./node_modules/tape/index.js
./node_modules/path-is-absolute/index.js
./node_modules/brace-expansion/index.js
./node_modules/deep-equal/index.js
./node_modules/has-symbols/index.js
./node_modules/has-symbols/test/index.js
./node_modules/shebang-regex/index.js
./node_modules/is-callable/index.js
./node_modules/through/index.js
./node_modules/through/test/index.js
./node_modules/resumer/index.js
./node_modules/resolve/index.js
./node_modules/resolve/test/resolver/dot_main/index.js
./node_modules/resolve/test/resolver/multirepo/packages/package-b/index.js
./node_modules/resolve/test/resolver/multirepo/packages/package-a/index.js
./node_modules/resolve/test/resolver/quux/foo/index.js
./node_modules/resolve/test/resolver/incorrect_main/index.js
./node_modules/resolve/test/resolver/same_names/foo/index.js
./node_modules/resolve/test/resolver/dot_slash_main/index.js
./node_modules/resolve/test/shadowed_core/node_modules/util/index.js
./node_modules/resolve/test/node_path/x/ccc/index.js
./node_modules/resolve/test/node_path/x/aaa/index.js
./node_modules/resolve/test/node_path/y/ccc/index.js
./node_modules/resolve/test/node_path/y/bbb/index.js
./node_modules/resolve/test/module_dir/ymodules/aaa/index.js
./node_modules/resolve/test/module_dir/xmodules/aaa/index.js
./node_modules/resolve/test/precedence/aaa/index.js
./node_modules/resolve/test/dotdot/abc/index.js
./node_modules/resolve/test/dotdot/index.js
./node_modules/function-bind/index.js
./node_modules/function-bind/test/index.js
./node_modules/shebang-command/index.js
./node_modules/minimist/index.js
./node_modules/cordova-plugin-network-information/src/blackberry10/index.js
./node_modules/cross-spawn/index.js
./node_modules/es-to-primitive/index.js
./node_modules/es-to-primitive/test/index.js
./node_modules/strip-bom/index.js
./node_modules/is-date-object/index.js
./node_modules/path-parse/index.js
./node_modules/is-symbol/index.js
./node_modules/is-symbol/test/index.js
./node_modules/base64-js/index.js
./node_modules/node-version-compare/index.js
./node_modules/node-version-compare/test/index.js
./node_modules/universalify/index.js
./node_modules/define-properties/index.js
./node_modules/define-properties/test/index.js
./node_modules/nice-try/src/index.js
./node_modules/defined/index.js
./node_modules/object-inspect/index.js
./node_modules/is-regex/index.js
./plugins/cordova-plugin-file/src/blackberry10/index.js
./plugins/cordova-plugin-network-information/src/blackberry10/index.js
质疑这些同名文件中的每一个文件的用途是什么是非常广泛和不切实际的,如果它们的存在取决于此项目以前的开发人员的设计选择,则有些文件可能无法回答。幸运的是,我可以说得更具体一些。我有一个问题需要调试,使用与bug相关的特定搜索字符串,我能够找到名为
index.js
的特定文件包含该字符串

$ grep -ril "<search_string>" .
./platforms/android/app/build/intermediates/assets/debug/www/js/index.js
./platforms/android/app/src/main/assets/www/js/index.js
./www/js/index.js
  • 问题1中提到的三个
    index.js
    文件是相同的。为什么这些相同的副本都存在

  • Cordova项目中存在名为
    index.js
    的不同文件。如果它们的内容不相同,为什么它们都叫同一个名字


  • 您应该编辑
    /www/js/index.js

    $ find . -name "index.js"
    ./platforms/android/app/build/intermediates/assets/debug/www/js/index.js
    ./platforms/android/app/src/main/assets/www/js/index.js
    ./platforms/android/cordova/node_modules/balanced-match/index.js
    ./platforms/android/cordova/node_modules/os-tmpdir/index.js
    ./platforms/android/cordova/node_modules/concat-map/index.js
    ./platforms/android/cordova/node_modules/properties-parser/index.js
    ./platforms/android/cordova/node_modules/elementtree/lib/parsers/index.js
    ./platforms/android/cordova/node_modules/os-homedir/index.js
    ./platforms/android/cordova/node_modules/xmlbuilder/lib/index.js
    ./platforms/android/cordova/node_modules/ansi/examples/beep/index.js
    ./platforms/android/cordova/node_modules/ansi/examples/progress/index.js
    ./platforms/android/cordova/node_modules/ansi/examples/clear/index.js
    ./platforms/android/cordova/node_modules/path-is-absolute/index.js
    ./platforms/android/cordova/node_modules/brace-expansion/index.js
    ./platforms/android/cordova/node_modules/sax/test/index.js
    ./platforms/android/cordova/node_modules/android-versions/index.js
    ./platforms/android/cordova/node_modules/lodash/index.js
    ./platforms/android/cordova/node_modules/cordova-registry-mapper/index.js
    ./www/js/index.js
    ./node_modules/objectorarray/index.js
    ./node_modules/es-abstract/index.js
    ./node_modules/es-abstract/test/index.js
    ./node_modules/isexe/index.js
    ./node_modules/balanced-match/index.js
    ./node_modules/object-keys/index.js
    ./node_modules/object-keys/test/index.js
    ./node_modules/has/src/index.js
    ./node_modules/has/test/index.js
    ./node_modules/semver/test/index.js
    ./node_modules/string.prototype.trim/index.js
    ./node_modules/string.prototype.trim/test/index.js
    ./node_modules/cordova-plugin-file/src/blackberry10/index.js
    ./node_modules/jsonfile/index.js
    ./node_modules/fs-extra/lib/ensure/index.js
    ./node_modules/fs-extra/lib/remove/index.js
    ./node_modules/fs-extra/lib/move/index.js
    ./node_modules/fs-extra/lib/output/index.js
    ./node_modules/fs-extra/lib/copy-sync/index.js
    ./node_modules/fs-extra/lib/fs/index.js
    ./node_modules/fs-extra/lib/empty/index.js
    ./node_modules/fs-extra/lib/index.js
    ./node_modules/fs-extra/lib/path-exists/index.js
    ./node_modules/fs-extra/lib/copy/index.js
    ./node_modules/fs-extra/lib/move-sync/index.js
    ./node_modules/fs-extra/lib/json/index.js
    ./node_modules/fs-extra/lib/mkdirs/index.js
    ./node_modules/concat-map/index.js
    ./node_modules/elementtree/lib/parsers/index.js
    ./node_modules/fs.realpath/index.js
    ./node_modules/plist/index.js
    ./node_modules/path-key/index.js
    ./node_modules/xmlbuilder/lib/index.js
    ./node_modules/ansi/examples/beep/index.js
    ./node_modules/ansi/examples/progress/index.js
    ./node_modules/ansi/examples/clear/index.js
    ./node_modules/cordova-android/node_modules/balanced-match/index.js
    ./node_modules/cordova-android/node_modules/os-tmpdir/index.js
    ./node_modules/cordova-android/node_modules/concat-map/index.js
    ./node_modules/cordova-android/node_modules/properties-parser/index.js
    ./node_modules/cordova-android/node_modules/elementtree/lib/parsers/index.js
    ./node_modules/cordova-android/node_modules/os-homedir/index.js
    ./node_modules/cordova-android/node_modules/xmlbuilder/lib/index.js
    ./node_modules/cordova-android/node_modules/ansi/examples/beep/index.js
    ./node_modules/cordova-android/node_modules/ansi/examples/progress/index.js
    ./node_modules/cordova-android/node_modules/ansi/examples/clear/index.js
    ./node_modules/cordova-android/node_modules/path-is-absolute/index.js
    ./node_modules/cordova-android/node_modules/brace-expansion/index.js
    ./node_modules/cordova-android/node_modules/sax/test/index.js
    ./node_modules/cordova-android/node_modules/android-versions/index.js
    ./node_modules/cordova-android/node_modules/lodash/index.js
    ./node_modules/cordova-android/node_modules/cordova-registry-mapper/index.js
    ./node_modules/cordova-android/bin/templates/project/assets/www/js/index.js
    ./node_modules/for-each/index.js
    ./node_modules/tape/index.js
    ./node_modules/path-is-absolute/index.js
    ./node_modules/brace-expansion/index.js
    ./node_modules/deep-equal/index.js
    ./node_modules/has-symbols/index.js
    ./node_modules/has-symbols/test/index.js
    ./node_modules/shebang-regex/index.js
    ./node_modules/is-callable/index.js
    ./node_modules/through/index.js
    ./node_modules/through/test/index.js
    ./node_modules/resumer/index.js
    ./node_modules/resolve/index.js
    ./node_modules/resolve/test/resolver/dot_main/index.js
    ./node_modules/resolve/test/resolver/multirepo/packages/package-b/index.js
    ./node_modules/resolve/test/resolver/multirepo/packages/package-a/index.js
    ./node_modules/resolve/test/resolver/quux/foo/index.js
    ./node_modules/resolve/test/resolver/incorrect_main/index.js
    ./node_modules/resolve/test/resolver/same_names/foo/index.js
    ./node_modules/resolve/test/resolver/dot_slash_main/index.js
    ./node_modules/resolve/test/shadowed_core/node_modules/util/index.js
    ./node_modules/resolve/test/node_path/x/ccc/index.js
    ./node_modules/resolve/test/node_path/x/aaa/index.js
    ./node_modules/resolve/test/node_path/y/ccc/index.js
    ./node_modules/resolve/test/node_path/y/bbb/index.js
    ./node_modules/resolve/test/module_dir/ymodules/aaa/index.js
    ./node_modules/resolve/test/module_dir/xmodules/aaa/index.js
    ./node_modules/resolve/test/precedence/aaa/index.js
    ./node_modules/resolve/test/dotdot/abc/index.js
    ./node_modules/resolve/test/dotdot/index.js
    ./node_modules/function-bind/index.js
    ./node_modules/function-bind/test/index.js
    ./node_modules/shebang-command/index.js
    ./node_modules/minimist/index.js
    ./node_modules/cordova-plugin-network-information/src/blackberry10/index.js
    ./node_modules/cross-spawn/index.js
    ./node_modules/es-to-primitive/index.js
    ./node_modules/es-to-primitive/test/index.js
    ./node_modules/strip-bom/index.js
    ./node_modules/is-date-object/index.js
    ./node_modules/path-parse/index.js
    ./node_modules/is-symbol/index.js
    ./node_modules/is-symbol/test/index.js
    ./node_modules/base64-js/index.js
    ./node_modules/node-version-compare/index.js
    ./node_modules/node-version-compare/test/index.js
    ./node_modules/universalify/index.js
    ./node_modules/define-properties/index.js
    ./node_modules/define-properties/test/index.js
    ./node_modules/nice-try/src/index.js
    ./node_modules/defined/index.js
    ./node_modules/object-inspect/index.js
    ./node_modules/is-regex/index.js
    ./plugins/cordova-plugin-file/src/blackberry10/index.js
    ./plugins/cordova-plugin-network-information/src/blackberry10/index.js
    
    其他两个文件是在生成过程中创建的。构建的Cordova应用程序将在android应用程序结构中包含所有
    www
    文件夹内容,这就是它们位于
    /platforms/android/app/src/main/


    另一个
    index.js
    文件在那里,因为它是一个Node.js模式

    我接受这个答案,因为它回答了我的问题,我对它投了更高的票,因为它清晰简洁。