Skip to content
This repository has been archived by the owner on Mar 15, 2018. It is now read-only.

The watch example doesn't work in my system #3

Closed
juanmanavarro opened this issue Jan 23, 2016 · 6 comments
Closed

The watch example doesn't work in my system #3

juanmanavarro opened this issue Jan 23, 2016 · 6 comments

Comments

@juanmanavarro
Copy link

It gives me this log:

0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node', '/usr/local/bin/npm', 'run', 'inject' ]
2 info using npm@3.3.12
3 info using node@v5.2.0
4 verbose run-script [ 'preinject', 'inject', 'postinject' ]
5 info lifecycle npm-scripts@1.0.0~preinject: npm-scripts@1.0.0
6 silly lifecycle npm-scripts@1.0.0~preinject: no script for preinject, continuing
7 info lifecycle npm-scripts@1.0.0~inject: npm-scripts@1.0.0
8 verbose lifecycle npm-scripts@1.0.0~inject: unsafe-perm in lifecycle true
9 verbose lifecycle npm-scripts@1.0.0~inject: PATH: /usr/local/lib/node_modules/npm/bin/node-gyp-bin:/var/www/html/test-projects/npm-scripts/node_modules/.bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/local/android-sdk-linux/tools:/usr/local/android-sdk-linux/platform-tools:/usr/local/android-sdk-linux:/usr/local/android-sdk-linux/platform-tools:/home/juanma/.composer/vendor/bin:/var/www/html/test-projects/node-bash:/var/www/html/test-projects/bash-scripts
10 verbose lifecycle npm-scripts@1.0.0~inject: CWD: /var/www/html/test-projects/npm-scripts
11 silly lifecycle npm-scripts@1.0.0~inject: Args: [ '-c',
11 silly lifecycle   'cat index.html | injectassets -G \'js/*.js;css/*.css\' -w -o index.html' ]
12 silly lifecycle npm-scripts@1.0.0~inject: Returned: code: 1  signal: null
13 info lifecycle npm-scripts@1.0.0~inject: Failed to exec inject script
14 verbose stack Error: npm-scripts@1.0.0 inject: `cat index.html | injectassets -G 'js/*.js;css/*.css' -w -o index.html`
14 verbose stack Exit status 1
14 verbose stack     at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/lifecycle.js:232:16)
14 verbose stack     at emitTwo (events.js:88:13)
14 verbose stack     at EventEmitter.emit (events.js:173:7)
14 verbose stack     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/spawn.js:24:14)
14 verbose stack     at emitTwo (events.js:88:13)
14 verbose stack     at ChildProcess.emit (events.js:173:7)
14 verbose stack     at maybeClose (internal/child_process.js:819:16)
14 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:212:5)
15 verbose pkgid npm-scripts@1.0.0
16 verbose cwd /var/www/html/test-projects/npm-scripts
17 error Linux 3.16.0-59-generic
18 error argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "inject"
19 error node v5.2.0
20 error npm  v3.3.12
21 error code ELIFECYCLE
22 error npm-scripts@1.0.0 inject: `cat index.html | injectassets -G 'js/*.js;css/*.css' -w -o index.html`
22 error Exit status 1
23 error Failed at the npm-scripts@1.0.0 inject script 'cat index.html | injectassets -G 'js/*.js;css/*.css' -w -o index.html'.
23 error Make sure you have the latest version of node.js and npm installed.
23 error If you do, this is most likely a problem with the npm-scripts package,
23 error not with npm itself.
23 error Tell the author that this fails on your system:
23 error     cat index.html | injectassets -G 'js/*.js;css/*.css' -w -o index.html
23 error You can get their info via:
23 error     npm owner ls npm-scripts
23 error There is likely additional logging output above.
24 verbose exit [ 1, true ]

I'm using Ubuntu 14

@ArnaudRinquin
Copy link
Contributor

I was able to reproduce and two issues happened, all fixed now and published as 1.0.6.

Note: You are trying to run cat index.html | injectassets -G 'js/*.js;css/*.css' -w -o index.html where the source template (index.html) would be overwritten in the process (as -o points to the same file) which would probably trigger an infinite loop. I would recommend not combining -w and writing the same file.

@juanmanavarro
Copy link
Author

Ok. Thank you. Is there any way to automatically inject an asset file every time I create a new one?

@ArnaudRinquin
Copy link
Contributor

Do you mind to elaborate?

every time I create a new one?

What do you mean by a new one?

If you're talking about the source template being regenerated and you want to re inject it, then I need watch mode to watch for the template as well. Shouldn't be too hard.

Your scenario (watch + inject right in the source template) however would not be possible: it would create and infinite loop.

@juanmanavarro
Copy link
Author

What I'm trying to achieve is every time I create a new js file in my
project, automatically inject the script tag in the index.html file. Is
this possible?

El 26/01/16 a las 10:35, Arnaud Rinquin escribió:

Do you mind to elaborate?

every time I create a new one?

What do you mean by /a new one/?


Reply to this email directly or view it on GitHub
#3 (comment).

@ArnaudRinquin
Copy link
Contributor

Yeah it's definitely possible, the command you tried to use would work. You should just change it so the source template and target output files are different, something like the following will work:

cat src/index.html | injectassets -g 'js/*.js;css/*.css' -w -o dist/index.html

Note the difference between -g and -G. The first lets you inject references while the other is for inlining content.

@juanmanavarro
Copy link
Author

Ok. Thank you for your help.

El 26/01/16 a las 10:56, Arnaud Rinquin escribió:

Yeah it's definitely possible, the command you tried to use would
work. You should just change it so the source template and target
output files are different, something like the following will work:

|cat src/index.html | injectassets -G 'js/.js;css/.css' -w -o
dist/index.html |


Reply to this email directly or view it on GitHub
#3 (comment).

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

No branches or pull requests

2 participants