Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to write file #31

Open
cladder opened this issue Apr 2, 2018 · 3 comments
Open

Failed to write file #31

cladder opened this issue Apr 2, 2018 · 3 comments

Comments

@cladder
Copy link

cladder commented Apr 2, 2018

Env: Win10
Err Message:

Making injector 'popup/index.js'
[16:45:24] 'manifest' errored after 33 ms
[16:45:24] Error: ENOENT: no such file or directory, open 'E:\web\extensions\qwt\build\popup\index.js'
    at Error (native)
    at Object.fs.openSync (fs.js:634:18)
    at Object.fs.writeFileSync (fs.js:1327:33)
    at exports.default (E:/web/extensions/qwt/dev-env/manifest/processor/lib/script.js:38:8)
    at exports.default (E:/web/extensions/qwt/dev-env/manifest/processor/lib/html.js:39:3)
    at process (E:/web/extensions/qwt/dev-env/manifest/processor/action.js:6:16)
    at exports.default (E:/web/extensions/qwt/dev-env/manifest/processor/action.js:21:3)
    at E:/web/extensions/qwt/dev-env/manifest/index.js:66:9
    at Array.forEach (native)
    at Manifest.processManifest (E:/web/extensions/qwt/dev-env/manifest/index.js:64:16)

how to solve this problem??

@cladder
Copy link
Author

cladder commented Apr 2, 2018

Well, I found the problem...
in file dev-env/manifest/processor/lib/script.js line 37

const injectorScript = makeInjector(scriptName);
    const injectorFilepath = path.join(buildPath, scriptName);
    const injectorPath = Remove.file(injectorFilepath)
    // problem goes here,injectorPath => ''???
    mkdirp.sync(injectorPath)
    // if I change to mkdirp.sync(path.dirname(injectorFilepath)) then it works.
    fs.writeFileSync(injectorFilepath, injectorScript, {encoding: 'utf8'})

    log.done()

@cladder
Copy link
Author

cladder commented Apr 2, 2018

应该是Remove.file的问题

var injectorFilePath = 'E:\web\extensions\qwt\build\popup\index.js';
Remove.file(injectorFilepath);     // ''

image
在win上路径会是\而不是/,这就是为什么会出问题了。dev-env/remove.js

export function file(filepath) {
   // not works on win32 because the path seperator is '\' but not '/'
  return filepath.split("/").slice(0,-1).join("/")
}

@cladder
Copy link
Author

cladder commented Apr 2, 2018

why not use path.dirname ? in file dev-env/remove.js I change it to

import path from 'path';
...
export const file = path.dirname;

and it works on my win10 laptop.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant