File tree Expand file tree Collapse file tree 3 files changed +14
-3
lines changed Expand file tree Collapse file tree 3 files changed +14
-3
lines changed Original file line number Diff line number Diff line change 18
18
#include < cctype>
19
19
#include < vector>
20
20
#include < algorithm>
21
+ #include < stdlib.h>
21
22
#include < sys/stat.h>
22
23
#include " file.hpp"
23
24
#include " context.hpp"
@@ -49,6 +50,15 @@ inline static std::string wstring_to_string(const std::wstring &wstr)
49
50
# endif
50
51
#endif
51
52
53
+ #ifdef _WASM
54
+ inline static std::string get_cwd_from_env ()
55
+ {
56
+ char * value = getenv (" PWD" );
57
+ if (!value) return " (unreachable)" ;
58
+ return value;
59
+ }
60
+ #endif
61
+
52
62
namespace Sass {
53
63
namespace File {
54
64
@@ -57,10 +67,10 @@ namespace Sass {
57
67
// always with trailing slash
58
68
std::string get_cwd ()
59
69
{
60
- const size_t wd_len = 4096 ;
61
70
#ifdef _WASM
62
- std::string cwd = " / " ;
71
+ std::string cwd = get_cwd_from_env () ;
63
72
#else
73
+ const size_t wd_len = 4096 ;
64
74
#ifndef _WIN32
65
75
char wd[wd_len];
66
76
char * pwd = getcwd (wd, wd_len);
Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ async function init() {
15
15
{ "wasi_unstable" : wrapper . exports }
16
16
) ;
17
17
host . args = [ wasmPath , ...process . argv . slice ( 2 ) ] ;
18
+ host . env = [ `PWD=${ process . cwd ( ) } ` ] ;
18
19
host . memory = sassc . exports . memory ;
19
20
return sassc . exports ;
20
21
}
Original file line number Diff line number Diff line change 1
1
{
2
2
"name": "sassc-wasi",
3
- "version": "0.1.0 ",
3
+ "version": "0.1.1 ",
4
4
"description": "",
5
5
"main": "index.js",
6
6
"scripts": {
You can’t perform that action at this time.
0 commit comments